Created
December 12, 2023 18:32
-
-
Save Sohamkadam333/bf5f2cd0973f3b2586fcb14deacf63db to your computer and use it in GitHub Desktop.
The AllocateAndInitializeSid function allocates and initializes a security identifier (SID) with up to eight subauthorities.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// AllocateAndInitializeSid function is part of the Windows API, specifically the Security Support Provider Interface (SSPI), and it is used for managing security identifiers (SIDs). SIDs are unique identifiers assigned to each security principal, such as a user or a group, in Windows. | |
#include <iostream> | |
#include <windows.h> | |
using namespace std; | |
int main() | |
{ | |
PSID psid = NULL; | |
SID_IDENTIFIER_AUTHORITY sidAuth = SECURITY_NT_AUTHORITY; | |
if(AllocateAndInitializeSid(&sidAuth,2,SECURITY_BUILTIN_DOMAIN_RID,DOMAIN_ALIAS_RID_ADMINS,0,0,0,0,0,0,&psid)) | |
{ | |
LPWSTR sidString; | |
if(ConvertSidToStringSidW(psid,&sidString)) | |
{ | |
wcout<<"SID "<<sidString<<endl; | |
LocalFree(sidString); | |
} | |
else | |
{ | |
cerr<<"Error converting Sid to string "<<endl; | |
} | |
FreeSid(psid); | |
} | |
else | |
{ | |
cerr<<"Error Allocating and initailizing sid"<<endl; | |
} | |
system("PAUSE"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment