IADsUser::ChangePassword method
Applies to: desktop apps only
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
- bstrOldPassword [in]
-
A BSTR that contains the current password.
- bstrNewPassword [out]
-
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 2000 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
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
DLL |
|
|
IID |
IID_IADsUser is defined as 3E37E320-17E2-11CF-ABC4-02608C9E7553 |
See also
Send comments about this topic to Microsoft
Build date: 2/3/2012
This doesn't occur when using NetUserChangePassword.
- 9/27/2010
- FrançoisB_