I wanted to post the solution to this problem so that it would be here at PH for others to see. I found it after spending time looking up security functions and testing things on my own.
BOOL bAdmin;
PSID pSecurity;
SID_IDENTIFIER_AUTHORITY siaLevel = SECURITY_NT_AUTHORITY;
//Check for administrator rights
if(AllocateAndInitializeSid(&siaLevel, 2, SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pSecurity) != 0)
{
CheckTokenMembership(NULL, pSecurity, &bAdmin);
FreeSid(pSecurity);
//We have to do this since MS won't use a real boolean
if(bAdmin)
this->bAdministrator = true;
}
else
return false;
Hope this helps somebody else.
*EDIT*
I wanted to point out that this code is inside a class method that returns a boolean (bool) type. That's why there is a "return false" statement if allocation fails.
-
Sephiroth