0

Say, if I get a user's SID with the following API:

TOKEN_USER* pTU = (TOKEN_USER*)pbytes;
DWORD dwSize;
GetTokenInformation(hToken, TokenUser, pTU, dwSize, &dwSize);

pTU->User.Sid;  //Contains the SID I need

I need to store this SID for later use/comparison in the program. But how do I copy it?

If I do this:

SID globalSIDStorage;
globalSIDStorage = *pTU->User.Sid;

I get an error that:

error C2679: binary '=' : no operator found which takes a right-hand operand of type 'PSID' (or there is no acceptable conversion.

ahmd0
  • 14,832
  • 29
  • 117
  • 218

1 Answers1

4

You probably want to use CopySid.

Jerry Coffin
  • 437,173
  • 71
  • 570
  • 1,035
  • Thanks. The issue here is knowing the SID length. Is there an API for that? Also from my rough calculation, if I store SID as a binary array, it will max out at 68 bytes. Can it be larger than that? – ahmd0 Feb 23 '13 at 23:40
  • 1
    OK, nevermind, it's `GetLengthSid`: http://msdn.microsoft.com/en-us/library/windows/desktop/aa446642(v=vs.85).aspx and the max SID size is in `SECURITY_MAX_SID_SIZE` – ahmd0 Feb 23 '13 at 23:46