Tag: administrator

C

Check if user is an administrator in C

AllocateAndInitializeSid – allocates and initializes a security identifier (SID) with up to eight subauthorities. CheckTokenMembership – determines whether a specified security identifier (SID) is enabled in an access token. #include <stdio.h> #include <stdlib.h> #include <windows.h> #include <stdbool.h>   bool isAdmin(void){ BOOL isadmin = false; SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY}; PSID AdministratorsGroup;   isadmin = AllocateAndInitializeSid( &NtAuthority, …