Condividi tramite


L'utente deve modificare la password all'accesso successivo (provider LDAP)

Per forzare un utente a modificare la password all'accesso successivo, impostare l'attributo pwdLastSet su zero (0). Per rimuovere questo requisito, impostare l'attributo pwdLastSet su -1. L'attributo pwdLastSet non può essere impostato su qualsiasi altro valore ad eccezione del sistema.

Nell'esempio di codice seguente viene illustrato come impostare l'opzione "L'utente deve modificare la password all'accesso successivo".

Dim usr as IADs

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

Nell'esempio di codice seguente viene illustrato come impostare l'opzione "L'utente deve modificare la password all'accesso successivo".

/***************************************************************************

    SetUserMustChangePassword()

***************************************************************************/

HRESULT SetUserMustChangePassword(LPCWSTR pwszUserADsPath, 
                                  LPCWSTR pwszUsername, 
                                  LPCWSTR pwszPassword)
{
    IADs *pUser;
    HRESULT hr;

    hr = ADsOpenObject(pwszUserADsPath,
                        pwszUsername,
                        pwszPassword,
                        ADS_SECURE_AUTHENTICATION,
                        IID_IADs,
                        (void**)&pUser);

    if(SUCCEEDED(hr))
    {
        VARIANT var;
        VariantInit(&var);
        V_I4(&var) = 0;
        V_VT(&var) = VT_I4;
        hr = pUser->Put(CComBSTR("pwdLastSet"), var);
        hr = pUser->SetInfo();

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

    return hr;
}