IMetabaseUser.ChangePassword

Syntax

ChangePassword(OldPassword: String, NewPassword: String);

Parameters

OldPassword. Old password.

NewPassword. New password.

Description

The ChangePassword method changes the user password.

Comments

The user who has the Changing Users Permissions, Giving Passwords, Changing Policy privilege can change the password of another user. The ADMIN user has this privilege by default. If the password is changed for another user, the empty value is passed as OldPassword. If the new password does not meet the requirements of the set security policy, the exception is thrown. Depending on the settings of the password policy, the old user password can be used to provide the password history. The password cannot be changed for the domain user. After change of the password the window of authorization on the server will be displayed for the user connected from the server.

Example

To execute the example, place on the form the Button component named Button1 and the EditBox component named EditBox1. Make sure that the security manager contains the USER user, and repository connection is established under the administrator account.

Add links to the Metabase, Forms, and Ui system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MB: IMetabase;
    User: IMetabaseUser;
    MS: IMetabaseSecurity;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Check out license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.Adm);
    MS := MB.Security;
    
// Change USER user password
    User := MS.ResolveName("USER"As IMetabaseUser;
    
Try
        User.ChangePassword(
"",EditBox1.Text);
    
Except
        
On E: Exception Do
        WinApplication.InformationBox(E.message);
    
End Try;
    
// Save changes
    MS.Apply;
    
// Check in license
    Lic := Null;
End Sub Button1OnClick;

Clicking the button changes password of the USER user for the new password specified in the EditBox1 component. If the new password does not meet the requirements of the security policy, the corresponding message is displayed.

See also:

IMetabaseUser