Platform SDK: Active Directory, ADSI, and Directory Services |
Account Expiration Date can be set using the AccountExpiration method in the IADsUser interface.
Set usr = GetObject("WinNT://Fabrikam/JSmith") usr.AccountExpirationDate = "05/06/1998" usr.SetInfo
To set the account expiration date to "never", use "January 1, 1970" as the parameter.
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 this property to "January 1, 1970".
Set usr = GetObject("WinNT://Fabrikam/JSmith") usr.AccountExpirationDate = "05/06/1998" usr.SetInfo // to enable the account forever, usr.AccountExpirationDate = "01/01/1970" usr.SetInfo
void SetUserAccountExpirationDate(IADsUser *pUser, DATE date) { if(!pUser) return; HRESULT hr = S_OK; hr = pUser->put_AccountExpirationDate(date); // expires on date hr = pUser->SetInfo(); hr = pUser->Release(); return; }