Share via


AllocateAndInitializeSid 函式 (securitybaseapi.h)

AllocateAndInitializeSid 函式會配置並初始化安全標識碼, (SID) 最多八個子授權。

語法

BOOL AllocateAndInitializeSid(
  [in]  PSID_IDENTIFIER_AUTHORITY pIdentifierAuthority,
  [in]  BYTE                      nSubAuthorityCount,
  [in]  DWORD                     nSubAuthority0,
  [in]  DWORD                     nSubAuthority1,
  [in]  DWORD                     nSubAuthority2,
  [in]  DWORD                     nSubAuthority3,
  [in]  DWORD                     nSubAuthority4,
  [in]  DWORD                     nSubAuthority5,
  [in]  DWORD                     nSubAuthority6,
  [in]  DWORD                     nSubAuthority7,
  [out] PSID                      *pSid
);

參數

[in] pIdentifierAuthority

SID_IDENTIFIER_AUTHORITY 結構的指標。 此結構提供在 SID 中設定的最上層識別碼授權單位值。

[in] nSubAuthorityCount

指定要放在 SID 中的子授權數目。 此參數也會識別有多少子授權參數具有有意義的值。 此參數必須包含從 1 到 8 的值。

例如,值為 3 表示 dwSubAuthority0dwSubAuthority1dwSubAuthority2 參數所指定的子授權值具有有意義的值,並忽略其餘值。

[in] nSubAuthority0

要放在 SID 中的子授權值。

[in] nSubAuthority1

要放在 SID 中的子授權值。

[in] nSubAuthority2

要放在 SID 中的子授權值。

[in] nSubAuthority3

要放在 SID 中的子授權值。

[in] nSubAuthority4

要放在 SID 中的子授權值。

[in] nSubAuthority5

要放在 SID 中的子授權值。

[in] nSubAuthority6

要放在 SID 中的子授權值。

[in] nSubAuthority7

要放在 SID 中的子授權值。

[out] pSid

變數的指標,接收已配置和初始化 SID 結構的指標。

傳回值

如果函式成功,則傳回非零的值。

如果此函式失敗,則傳回值為零。 若要取得擴充的錯誤資訊,請呼叫 GetLastError

備註

使用 AllocateAndInitializeSid 函式配置的 SID 必須使用 FreeSid 函式釋放。

此函式會建立具有 32 位 RID 值的 SID。 對於需要較長 RID 值的應用程式,請使用 CreateWellKnownSid

範例

如需使用此函式的範例,請參閱 建立新物件的安全性描述元取得對象擁有權

規格需求

需求
最低支援的用戶端 Windows XP [傳統型應用程式 |UWP 應用程式]
最低支援的伺服器 Windows Server 2003 [傳統型應用程式 |UWP 應用程式]
目標平台 Windows
標頭 securitybaseapi.h (包含 Windows.h)
程式庫 Advapi32.lib
Dll Advapi32.dll

另請參閱

存取控制

基本 存取控制 函式

FreeSid

GetSidIdentifierAuthority

InitializeSid

SID_IDENTIFIER_AUTHORITY

已知的 SID