共用方式為


NetRemoveServiceAccount 函式 (lmaccess.h)

如果帳戶是獨立受控服務帳戶,則 NetRemoveServiceAccount 函式會從 Active Directory 資料庫刪除指定的服務帳戶, (sMSA) 。 對於群組受管理的服務帳戶 (gMSA) ,此函式不會從 Active Directory 資料庫刪除帳戶。 sMSA 和 gMSA (LSA) 中儲存的密碼會同時刪除,且狀態會儲存在 Netlogon 登錄存放區中。

此函式沒有相關聯的匯入程式庫。 您必須使用 LoadLibraryGetProcAddress 函式,動態連結至 Logoncli.dll。

語法

NTSTATUS NetRemoveServiceAccount(
  [in, optional] LPWSTR ServerName,
  [in]           LPWSTR AccountName,
  [in]           DWORD  Flags
);

參數

[in, optional] ServerName

此參數的值必須是 Null

[in] AccountName

要刪除的帳戶名稱。

[in] Flags

此參數可以有下列值。

意義
SERVICE_ACCOUNT_FLAG_UNLINK_FROM_HOST_ONLY
0x00000001
針對 sMSA,服務帳戶物件會從本機電腦取消連結,而且會刪除儲存在 LSA 中的秘密。 服務帳戶物件不會從 Active Directory 資料庫中刪除。 此旗標對 gMSA 沒有意義。

傳回值

如果函式成功,則會 傳回STATUS_SUCCESS

如果函式失敗,它會傳回錯誤碼。

需求

   
最低支援的用戶端 Windows 7 [僅限傳統型應用程式]
最低支援的伺服器 Windows Server 2008 R2 [僅限桌面應用程式]
目標平台 Windows
標頭 lmaccess.h
Dll Netapi32.dll

另請參閱

NetAddServiceAccount

NetEnumerateServiceAccounts

NetIsServiceAccount