Platform SDK: Active Directory, ADSI, and Directory Services |
You can set the account expiration date by setting the AccountExpirationDate property of the IADsUser interface to a desired date value. To set the account expiration date to "never", set the AccountExpires attribute to –1.
Set usr = GetObject("LDAP://CN=Jeff smith, OU=Sales, DC=Fabrikam, DC=Com") usr.AccountExpirationDate = "05/06/1998" usr.SetInfo // to enable the account forever, usr.Put "AccountExpires",-1 usr.SetInfo
void SetUserAccountExpirationDate(IADsUser *pUser, DATE date) { if(!pUser) return; if(!date || date<0) { VARIANT var; VariantInit(&var); V_I4(&var)=-1; V_VT(&var)=VT_I4; hr = pUser->Put(L"accountExpires", var); // never expires. VariantClear(&var); } else { HRESULT hr = S_OK; hr = pUser->put_AccountExpirationDate(date); // expires on date } hr = pUser->SetInfo(); hr = pUser->Release(); return; }