Platform SDK: Active Directory, ADSI, and Directory Services

Account Disabled

You can disable a user account by setting the AccountDisabled property to True in the IADsUser interface. This is similar to the WinNT provider.

Example Code [Visual Basic]

Set usr = GetObject("LDAP:// CN=Jsmith, OU=Sales, DC=Fabrikam, DC=Com")
usr.AccountDisabled = TRUE 'disabled the account
usr.SetInfo

Example Code [C++]

IADsUser *pUser;

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

hr = pUser->put_AccountDisabled(true);
hr = pUser->SetInfo();