src/Helpers.c
bool IsUserAdmin()
{
  PSID pAdminGroup;
  SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
  BOOL bIsAdmin = AllocateAndInitializeSid(&NtAuthority, 2,
    SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pAdminGroup);
  if (bIsAdmin) {
    if (!CheckTokenMembership(NULL, pAdminGroup, &bIsAdmin)) {
      bIsAdmin = false;
    }
    FreeSid(pAdminGroup);
  }
  return bIsAdmin;
}
//=============================================================================
//
//  IsUserAdmin()
//
// Routine Description: This routine returns TRUE if the caller's
// process is a member of the Administrators local group. Caller is NOT
// expected to be impersonating anyone and is expected to be able to
// open its own process and process token.
// Arguments: None.
// Return Value:
// true - Caller has Administrators local group.
// false - Caller does not have Administrators local group. --
//
IsUserAdmin()
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group. Caller is NOT
expected to be impersonating anyone and is expected to be able to
open its own process and process token.
Arguments: None.
Return Value:
true - Caller has Administrators local group.
false - Caller does not have Administrators local group.
IsUserAdmin () Routine Description : This routine returns TRUE if the caller ' s process is a member of the Administrators local group . Caller is NOT expected to be impersonating anyone and is expected to be able to open its own process and process token . Arguments : None . Return Value : true - Caller has Administrators local group . false - Caller does not have Administrators local group .
bool IsUserAdmin()
{
  PSID pAdminGroup;
  SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY;
  BOOL bIsAdmin = AllocateAndInitializeSid(&NtAuthority, 2,
    SECURITY_BUILTIN_DOMAIN_RID, DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &pAdminGroup);
  if (bIsAdmin) {
    if (!CheckTokenMembership(NULL, pAdminGroup, &bIsAdmin)) {
      bIsAdmin = false;
    }
    FreeSid(pAdminGroup);
  }
  return bIsAdmin;
}
bool IsUserAdmin ( ) { PSID pAdminGroup ; SID_IDENTIFIER_AUTHORITY NtAuthority = SECURITY_NT_AUTHORITY ; BOOL bIsAdmin = AllocateAndInitializeSid ( & NtAuthority , 2 , SECURITY_BUILTIN_DOMAIN_RID , DOMAIN_ALIAS_RID_ADMINS , 0 , 0 , 0 , 0 , 0 , 0 , & pAdminGroup ) ; if ( bIsAdmin ) { if ( ! CheckTokenMembership ( NULL , pAdminGroup , & bIsAdmin ) ) { bIsAdmin = false ; } FreeSid ( pAdminGroup ) ; } return bIsAdmin ; }
IsUserAdmin()
Routine Description: This routine returns TRUE if the caller's
process is a member of the Administrators local group.
IsUserAdmin () Routine Description : This routine returns TRUE if the caller ' s process is a member of the Administrators local group .