EN
このコンテンツは設定された言語で表示できません。英語版のページが表示されます。

IADsUser::ChangePassword method

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 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 Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Iads.h

DLL

Activeds.dll

IID

IID_IADsUser is defined as 3E37E320-17E2-11CF-ABC4-02608C9E7553

See also

IADsUser
IADsUser Property Methods
ADSI Error Codes

 

 

表示:
© 2014 Microsoft