CreateWellKnownSid function
The CreateWellKnownSid function creates a SID for predefined aliases.
Syntax
BOOL WINAPI CreateWellKnownSid( _In_ WELL_KNOWN_SID_TYPE WellKnownSidType, _In_opt_ PSID DomainSid, _Out_opt_ PSID pSid, _Inout_ DWORD *cbSid );
Parameters
- WellKnownSidType [in]
-
Member of the WELL_KNOWN_SID_TYPE enumeration that specifies what the SID will identify.
- DomainSid [in, optional]
-
A pointer to a SID that identifies the domain to use when creating the SID. Pass NULL to use the local computer.
- pSid [out, optional]
-
A pointer to memory where CreateWellKnownSid will store the new SID.
- cbSid [in, out]
-
A pointer to a DWORD that contains the number of bytes available at pSid. The CreateWellKnownSid function stores the number of bytes actually used at this location.
Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. For extended error information, call GetLastError.
Examples
The following example shows creating a SID for the Everyone group.
DWORD SidSize; PSID TheSID; LPTSTR p; SidSize = SECURITY_MAX_SID_SIZE; // Allocate enough memory for the largest possible SID. if(!(TheSID = LocalAlloc(LMEM_FIXED, SidSize))) { fprintf(stderr, "Could not allocate memory.\n"); exit(1); } // Create a SID for the Everyone group on the local computer. if(!CreateWellKnownSid(WinWorldSid, NULL, TheSID, &SidSize)) { fprintf(stderr, "CreateWellKnownSid Error %u", GetLastError()); } else { // Get the string version of the SID (S-1-1-0). if(!(ConvertSidToStringSid(TheSID, &p))) { fprintf(stderr, "Error during ConvertSidToStringSid.\n"); exit(1); } // Use the string SID as needed. // ... // When done, free the memory used. LocalFree(p); LocalFree(TheSID); }
Requirements
|
Minimum supported client |
Windows XP [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2003 [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also