Directory Services |
The IADsUser::ChangePassword method changes the user password from the specified old value to a new value.
HRESULT ChangePassword( BSTR bstrOldPassword, BSTR bstrNewPassword );
The method used to change the password is provider-specific. The system LDAP provider initially attempts a LDAP change password operation, if a secure SSL connection to the server is established. If this attempt fails, the LDAP provider then calls the Active Directory specific network management API, NetUserChangePassword.
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 the password of a user.
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; }
Client: Included in Windows XP and
Windows 2000 Professional.
Server: Included in Windows Server 2003 and
Windows 2000 Server.
Redistributable: Requires Active Directory Client Extension
on Windows NT 4.0 SP6a and Windows 95/98/Me.
Header: Declared in Iads.h.