Occurs when a password is changed or is reset.
The event handler receives an argument of type VGValidatePasswordEventArgs containing data related to this event. The following VGValidatePasswordEventArgs properties provide information specific to this event.
Property | Description |
---|---|
Cancel | Gets or sets a value that indicates whether the current create-user, change-password, or reset-password action will be canceled. |
FailureInformation | Gets or sets an exception that describes the reason for the password-validation failure. |
IsNewUser | Gets a value that indicates whether the ValidatingPassword event is being raised during a call to the CreateUser method. |
Password | Gets the password for the current create-user, change-password, or reset-password action. |
UserName | Gets the name of the membership user for the current create-user, change-password, or reset-password action. |
The event handler receives an argument of type VGValidatePasswordEventArgs containing data related to this event. The ValidatingPassword
event allows to cancel the password modification when the password is not valid.
This example show a ValidatingPassword event that checks whether the password does not contain a list of invalid string.
[Visual Basic]
Private Sub OnValidatingPassword(ByVal sender As Object, ByVal e As VGValidatePasswordEventArgs)
Dim invalidText() As String = New String() {"password", "novalys", "aaa", "bbb", "ccc"}
For Each text As String In invalidText
If e.Password.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0 Then
e.Cancel = True
Return
End If
Next
If e.Password.IndexOf(e.UserName, StringComparison.CurrentCultureIgnoreCase) >= 0 Then
e.Cancel = True
End If
End Sub
[C#]
private void OnValidatingPassword (object sender, VGValidatePasswordEventArgs args)
{
string[] invalidText = new string[] { "pwd", "password", "passwd", "aaa", "bbb" };
foreach (string text in invalidText)
{
if (e.Password.IndexOf(text, StringComparison.CurrentCultureIgnoreCase) >= 0
{
e.Cancel = true;
return;
}
}
if (e.Password.IndexOf(e.UserName, StringComparison.CurrentCultureIgnoreCase) >= 0)
{
e.Cancel = true;
}
}
VGSecurityManager Class | Novalys.VisualGuard.Security Namespace