IPasswordHistory.Contains

Syntax

Contains(PasswordHash: String): Boolean;

Parameters

PasswordHash - custom password that was hashed.

Description

The Contains method returns whether password is contained in history. True - password is in history, False - password is absent in history.

Example

Executing the example requires a form, a button with the Button1 identifier on it, the EditBox component with the EditBox1 identifier and the Memo component with the Memo1 identifier. The example is executed on clicking the button.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);

Var

Mb: IMetabase;

MbUser: IMetabaseUser;

MbSecurity: IMetabaseSecurity;

HashP: String;

MbPassHistory: IPasswordHistory;

Begin

Mb := MetabaseClass.Active;

MbSecurity := Mb.Security;

MbUser := MbSecurity.ResolveName("ADMIN") As IMetabaseUser;

HashP := MbSecurity.HashPassword(EditBox1.Text);

MbPassHistory := MbUser.PasswordHistory;

If MbPassHistory.Contains(HashP) Then

Memo1.Lines.Add("Password '" + EditBox1.Text + "' is already in history");

Else MbPassHistory.Insert(HashP);

Memo1.Lines.Add("Password '" + EditBox1.Text + "' is added in history");

End If;

MbSecurity.Apply;

End Sub Button1OnClick;

After executing this example the password entered by the user in the EditBox component is checked whether it is in history. The result of check is displayed in the Memo component.

See also:

IPasswordHistory