CreateWellKnownSid

王朝百科·作者佚名  2011-07-02
窄屏简体版  字體: |||超大  

函数功能创建一个SID(安全描述符)

函数原型BOOL WINAPI CreateWellKnownSid( __in WELL_KNOWN_SID_TYPE WellKnownSidType, __in_opt PSID DomainSid, __out_opt PSID pSid, __inout DWORD *cbSid);

参数:

WellKnownSidType SID类型,WELL_KNOWN_SID_TYPE是枚举类型,它包含一系列的安全描述符类型

DomainSid 指向创建了SID的域的指针,为NULL时表示使用本地计算机

pSid 指向存储SID的地址

cbSid 指向存储pSid的大小的地址

返回值函数成功执行,返回非0的值;

执行失败,返回值为0。想进一步了解错误信息,执行GetLastError.

举例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.

"); 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.

"); exit(1); } // Use the string SID as needed. // ... // When done, free the memory used. LocalFree(p); LocalFree(TheSID); }

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航