Directory Services

Account Expiration

The account expiration date can be set using the AccountExpiration method in the IADsUser interface.

To set the account expiration date, set the AccountExpirationDate property of the IADsUser interface to a desired date value. To set the account expiration date to never expire, set this property to "January 1, 1970". The following code examples show how to set the account expiration date.

Example Code [Visual Basic]

Dim usr As IADsUser

Set usr = GetObject("WinNT://Fabrikam/JeffSmith")
usr.AccountExpirationDate = "05/06/1998"
' Set the account to never expire.
usr.AccountExpirationDate = "01/01/1970"

Example Code [C++]

void SetUserAccountExpirationDate(IADsUser *pUser, DATE date)
   if(!pUser) return;

   HRESULT hr = S_OK;
   hr = pUser->put_AccountExpirationDate(date); // Set the account to expires on date.
   hr = pUser->SetInfo();
   hr = pUser->Release();