Platform SDK: Active Directory, ADSI, and Directory Services

User Must Change Password at Next Logon

To enable this option, set the pwdLastSet attribute to zero(0). To clear this flag, set the attribute to -1.

Example Code [Visual Basic]

Set usr = GetObject("LDAP://CN=Jeff Smith, OU=Sales, DC=Acme, DC=Com")
usr.Put "pwdLastSet", CLng(0)
usr.SetInfo

Example Code [C++]

IADsUser *pUser;
HRESULT hr;

hr=ADsGetObject(L"LDAP://cn=Jeff Smith,cn=users,dc=Fabrikam,dc=com",
                IID_IADsUser,
                (void**)&pUser);
VARIANT var;
VariantInit(&var);
V_I4(&var)=0;
V_VT(&var)=VT_I4;
hr = pUser->Put(L"pwdLastSet",var);
hr = pUser->SetInfo();

VariantClear(&var);
pUser->Release();