Gets a VGAuthenticationState object representing the last authentication state.
You can use this value to test if the last authentication has failed or not and to check reason of the failure.
The following example displays how to test the state of the authentication
[C#]
VGAuthenticationState state = VGSecurityManager.Authenticate(user.Text, password.Text);
if (state.IsFailed)
{
if (state.IsCanceled) return;
if (state.IsCredentialInvalid)
{
if (state.IsLastBadLogin)
{
MessageBox.Show("Invalid user or password. The next bad login will lock your account.");
}
else
{
MessageBox.Show("Invalid user or password");
}
}
else if (state.IsUserNotAuthorized)
{
MessageBox.Show("user not authorized to log on the application");
}
else if (state.IsUserAccountExpired)
{
MessageBox.Show("your account is no more valid. Contact your administrator");
}
else if (state.IsUserAccountNotYetAvailable)
{
MessageBox.Show("your account is not yet available.");
}
else if (state.IsUserAccountLockedOut)
{
MessageBox.Show("your account is locked. Contact your administrator.");
}
}
else
{
if (state.IsPasswordSecured)
{
this.DialogResult = DialogResult.OK;
return;
}
else if (state.IsLastGraceLogon)
{
MessageBox.Show("You must change your password");
ChangePassword form = new ChangePassword();
form.ShowDialog();
}
else
{
MessageBox.Show("Your password is not enough secure. Do not forget to change it.");
}
}
[Visual Basic]
Dim state As VGAuthenticationState = VGSecurityManager.Authenticate(userTextBox.Text, passwordTextBox.Text)
If state.IsFailed Then
Me.DialogResult = DialogResult.None
If state.IsCanceled Then Return
If state.IsCredentialInvalid Then
If state.IsLastBadLogin Then
MessageBox.Show("Invalid user or password. The next bad login will lock your account.")
Else
MessageBox.Show("Invalid user or password")
End If
ElseIf state.IsUserNotAuthorized Then
MessageBox.Show("user not authorized to log on to the application")
ElseIf state.IsUserAccountExpired Then
MessageBox.Show("your account is no more valid. Contact your administrator")
ElseIf state.IsUserAccountNotYetAvailable Then
MessageBox.Show("your account is not yet available.")
ElseIf state.IsUserAccountLockedOut Then
MessageBox.Show("your account is locked. Contact your administrator.")
End If
Else
Me.DialogResult = DialogResult.OK
If state.IsPasswordSecured Then
Return
ElseIf state.IsLastGraceLogon Then
MessageBox.Show("You must change your password")
Dim form As ChangePassword = New ChangePassword
form.ShowDialog()
Else
MessageBox.Show("Your password is not enough secure. Do not forget to change it.")
End If
End If
VGSecurityManager Class | Novalys.VisualGuard.Security Namespace