IMetabaseUser.ChangePassword

Syntax

ChangePassword(OldPassword: String, NewPassword: String);

ChangePassword(System.String, System.String);

Parameters

OldPassword. An old password.

NewPassword. A new password.

Description

The ChangePassword method changes the user password.

Comments

The user who has the "Change of users rights, distribution of passwords, change of policy" privilege, can change the password of another user. ADMIN 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 satisfy the requirements of the set security policy, the exception condition is generated. Depending on the settings of the password policy, the old user password can be used to provide the password history. The password can not be changed for the domain user. After change of the password the window of authorization on the server will be shown for the user that is connected from the server.

Example

To execute the example, place the Button and EditBox components (for Fore.NET example use the TextBox component) named Button1, EditBox1/TextBox1 correspondingly on the form. Make sure that the security manager contains the USER user, and repository connection is established under the administrator account.

Add links to the system assemblies:

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    MB: IMetabase;
    User: IMetabaseUser;
    MS: IMetabaseSecurity;
    Lic: Object;
Begin
    MB := MetabaseClass.Active;
    
// Get 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;

Imports Prognoz.Platform.Forms.Net;
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;

Private Sub button1_Click(sender: System.Object; e: System.EventArgs);
Var
    MB: IMetabase;
    User: IMetabaseUser;
    MS: IMetabaseSecurity;
    Lic: Object;
Begin
    MB := Self.Metabase;
    
// Get license to work with security manager
    Lic := MB.RequestLicense(UiLicenseFeatureType.lftAdm);
    MS := MB.Security;
    
// Change USER user password
    User := MS.ResolveName("USER"As IMetabaseUser;
    
Try
        User.ChangePassword(
"",TextBox1.Text);
    
Except
        
On Ef: System.Exception Do
        MessageBox.Show(Ef.message);
    
End Try;
    
// Save changes
    MS.Apply();
    
// Check in license
    Lic := Null;
End Sub;

Clicking the button changes password of the USER user for the new password specified in the EditBox1/TextBox1 component. If the new password does not satisfy the requirements of the security policy, the appropriate message is shown.

See also:

IMetabaseUser