帐户已禁用 (LDAP 提供程序)
若要禁用用户帐户,请在 IADsUser 接口中将 AccountDisabled 属性设置为 TRUE。 这类似于 WinNT 提供程序。 以下代码示例演示如何禁用用户帐户。
示例 1
Dim usr As IADsUser
On Error GoTo Cleanup
Set usr = GetObject("LDAP:// CN=JeffSmith, OU=Sales, DC=Fabrikam, DC=Com")
usr.AccountDisabled = TRUE ' Disable the account.
usr.SetInfo
Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set usr = Nothing
示例 2
IADsUser *pUser = NULL;
HRESULT hr = S_OK;
LPWSTR adsPath;
adsPath=L"LDAP://serv1/cn=Jeff Smith,cn=Users, dc=Fabrikam, dc=com";
hr = ADsGetObject(adsPath,IID_IADsUser,(void**)&pUser);
if(FAILED(hr)){return;}
hr = pUser->put_AccountDisabled(true);
hr = pUser->SetInfo();