Directory Services

Password Never Expires

To enable this option using ADSI's WinNT provider, set the ADS_UF_DONT_EXPIRE_PASSWD(0x10000) bit on the UserFlags attribute.

Note  For Windows 2000 and later, use ADSI's LDAP provider for user management operations like this. See Password Never Expires in the ADSI LDAP Provider documentation.

Example Code [Visual Basic]

Set usr = GetObject("WinNT://Fabrikam/JeffSmith")
flag = usr.Get("UserFlags")
newFlag = flag Or ADS_UF_DONT_EXPIRE_PASSWD
usr.Put "userFlags", newFlag
usr.SetInfo

Example Code [C++]

#include <activeds.h>

IADsUser *pUser = NULL;
VARIANT var;
VariantInit(&var);

HRESULT hr = S_OK;
LPWSTR adsPath;
adsPath=L"WinNT://Fabrikam/JeffSmith";
hr = ADsGetObject(adsPath,IID_IADsUser,(void**)&pUser);

hr = pUser->Get(L"UserFlags",&var);

V_I4(&var) |= ADS_UF_DONT_EXPIRE_PASSWD;
hr = pUser->Put(CComBSTR("UserFlags"), var);

hr = pUser->SetInfo();
VariantClear(&var);
hr = pUser->Release();