Directory Services

Account Lockout

Like the WinNT provider, in the LDAP provider, you can only set the account lockout to FALSE, which unlocks the account. Only the system can set the account lockout to TRUE. You can also read the value of the account lockout.

Example Code [Visual Basic]

Dim usr As IADsUser
On Error GoTo Cleanup

Set usr = GetObject("LDAP://CN=Jeff Smith, OU=Sales, DC=Fabrikam, DC=Com")
usr.IsAccountLocked = FALSE
usr.SetInfo

Cleanup:
	If (Err.Number<>0) Then
		MsgBox("An error has occurred. " & Err.Number)
	End If
	Set usr = Nothing

Example Code [C++]

IADsUser *pUser = NULL;
HRESULT hr = S_OK;
LPWSTR adsPath = L"LDAP://CN=Jeff Smith, OU=Sales, DC=Fabrikam, DC=Com";

hr = ADsOpenObject(adsPath,NULL,NULL,ADS_SECURE_AUTHENTICATION,
				 IID_IADsUser,(void**)&pUser);

If(FAILED(hr)){return hr};

hr = pUser->put_IsAccountLocked(FALSE);
hr = pUser->SetInfo();

hr = pUser->Release();