Platform SDK: Active Directory, ADSI, and Directory Services

Account Disabled

Example Code [Visual Basic]

Set usr = GetObject("WinNT://Fabrikam/JSmith")
usr.AccountDisabled = TRUE 'disabled the account
usr.SetInfo

Example Code [C++]

IADsUser *pUser;

HRESULT hr = S_OK;
LPWSTR adsPath;
adsPath=L"WinNT://Fabrikam/JSmith";
hr = ADsGetObject(adsPath,IID_IADsUser,(void**)&pUser);

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