Account Expiration (WinNT Provider)

When using the WinNT provider, the account expiration date can be set using the IADsUser.AccountExpirationDate property.

To set the account expiration date, set the IADsUser.AccountExpirationDate property to the desired date value. To set the account expiration date to never expire, set this property to "January 1, 1970".

Example 1

The following code example shows how to set the account expiration date using Visual Basic with ADSI.

Dim usr As IADsUser

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

Example 2

The following code example shows how to set the account expiration date using C++ with ADSI.

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();
   return;
}