Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The IADsUser::SetPassword method sets the user password to a specified value. For the LDAP provider, the user account must have been created and stored in the underlying directory using IADs::SetInfo before IADsUser::SetPassword is called.
The WinNT provider, however, enables you to set the password on a newly created user object prior to calling SetInfo. This ensures that you create passwords that comply with the system password policy before you create the user account.
HRESULT SetPassword(
BSTR NewPassword
);
NewPassword
A BSTR that contains the new password.
This method supports the standard return values, including S_OK. For other return values, see ADSI Error Codes.
The LDAP provider for Active Directory uses one of three processes to set the password; third-party LDAP directories such as iPlanet do not use this password authentication process. The method may vary according to the network configuration. Attempts to set the password occur in the following order:
The following code example shows how to set the user password, if you have the permission to do so.
Dim usr As IADsUser
Dim szPassword As String
On Error GoTo Cleanup
' Add code to securely get the password.
Set usr = GetObject("LDAP://MyLdapSvr/CN=JeffSmith,DC=Fabrikam")
usr.SetPassword szPassword
Cleanup:
If (Err.Number<>0) Then
MsgBox("An error has occurred. " & Err.Number)
End If
Set usr = Nothing
The following code example shows how to set the user password, if you have the permission to do so.
HRESULT SetPassword(IADsUser *pUser, BSTR password)
{
HRESULT hr=S_OK;
if(!pUser) { return E_FAIL;}
hr = pUser->SetPassword(password);
if (hr == S_OK) printf("User password has been set");
pUser->Release();
return hr;
}
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | iads.h |
DLL | Activeds.dll |
Events
May 19, 6 PM - May 23, 12 AM
Calling all developers, creators, and AI innovators to join us in Seattle @Microsoft Build May 19-22.
Register today