I already asked about how to get the user name.
How can I get the user name who invoked the method of COM server?
Now I need to get the SID too. How do I do this?
The OpenProcessToken approach doesn’t work because this function fails with ERROR_BAD_IMPERSONATION_LEVEL error.
UPDATE
In order to do this, the client should allow the server to get its information by configuring the proxy with CoSetProxyBlanket API as shown below:
Then being impersonated (CoImpersonateClient) you may access the user’s token with OpenThreadToken.
END OF UPDATE
And after that you may use GetTokenInformation API as follows:
tokenInfo will contain the field User.Sid of type PSID.