IADsUser::ChangePassword method (iads.h)
The IADsUser::ChangePassword method changes the user password from the specified old value to a new value.
Syntax
HRESULT ChangePassword(
[in] BSTR bstrOldPassword,
[out] BSTR bstrNewPassword
);
Parameters
[in] bstrOldPassword
A BSTR that contains the current password.
[out] bstrNewPassword
A BSTR that contains the new password.
Return value
This method supports the standard return values, including S_OK. For more information and other return values, see ADSI Error Codes.
Remarks
IADsUser::ChangePassword functions similarly to IADsUser::SetPassword in that it will use one of three methods to try to change the password. Initially, the LDAP provider will attempt an LDAP change password operation, if a secure SSL connection to the server is established. If this attempt fails, the LDAP provider will next try to use Kerberos (see IADsUser::SetPassword for some problems that may result on Windows with cross-forest authentication), and if this also fails, it will finally call the Active Directory specific network management API, NetUserChangePassword.
In Active Directory, the caller must have the Change Password extended control access right to change the password with this method.
Examples
The following code example shows how to change a user password.
Dim usr As IADsUser
Dim szOldPass As String
Dim szNewPass As String
On Error GoTo Cleanup
Set usr = GetObject("WinNT://Fabrikam/JeffSmith,user")
' Add code to securely retrieve the old and new password.
usr.ChangePassword szOldPass, szNewPass
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 change a user password.
HRESULT ChangePassword(
IADsUser *pUser,
LPWSTR oldPasswd,
LPWSTR newPasswd)
{
HRESULT hr=S_OK;
if(!pUser) { return E_FAIL;}
hr = pUser->ChangePassword(oldPasswd, newPasswd);
printf("User password has been changed");
return hr;
}
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Vista |
Minimum supported server | Windows Server 2008 |
Target Platform | Windows |
Header | iads.h |
DLL | Activeds.dll |