Click or drag to resize

VGAuthenticationState Class

Defines the state of an authentication process.
Inheritance Hierarchy
SystemObject
  Novalys.VisualGuard.SecurityVGAuthenticationState

Namespace:  Novalys.VisualGuard.Security
Assembly:  Novalys.VisualGuard.Security (in Novalys.VisualGuard.Security.dll) Version: 2019.1.831.19 (2019.1.0831.19)
Syntax
public sealed class VGAuthenticationState

The VGAuthenticationState type exposes the following members.

Constructors
  NameDescription
Public methodVGAuthenticationState
Creates a new instance of VGAuthenticationState.
Top
Properties
  NameDescription
Public propertyIsCanceled
Checks whether the authentication process has been canceled by the user.
Public propertyIsCredentialInvalid
Checks whether the authentication process has failed due to bad credentials (user or password incorrect).
Public propertyIsFailed
Checks if the authentication process has failed
Public propertyIsLastBadLogin
Checks whether the next bad logon attempt will lock out the user account.
Public propertyIsLastGraceLogon Obsolete.
Checks whether it is the last grace logon before locking out the account.
Public propertyIsNotApproved
Checks whether the user is not approved and cannot be authenticated.
Public propertyIsPasswordExpired
Checks whether the password is expired according to the password policy.
Public propertyIsPasswordSecure
Checks whether the password is secure enough according to the password policy.
Public propertyIsUserAccountDisabled
Checks whether user account is disabled.
Public propertyIsUserAccountExpired
Checks whether the user account has expired.
Public propertyIsUserAccountLocked
Checks whether user account is locked
Public propertyIsUserAccountLockedOut
Checks whether the user account is locked out due to bad credentials.
Public propertyIsUserAccountNotYetAvailable
Checks whether the user account exists but is not yet available.
Public propertyIsUserAccountWillBeLockedOut
Checks whether the user account will be locked out for the next logon attempt.
Public propertyIsUserNotAuthorized
Checks whether the user is not authorized to access to the application.
Public propertyMustChangePasswordAtNextLogon
Checks whether the user must change the password at next logon.
Public propertyStatus
Gets a VGAuthenticationStatus corresponding to the authentication state.
Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Convert the state to a string value.
(Overrides ObjectToString.)
Top
Examples
The following example displays how to test the state of the authentication
Reauthenticate:
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 out. Contact your administrator.");
    }
    else if (state.MustChangePasswordAtNextLogon)
    {
        if (!state.IsPasswordSecure)
        {
            if (state.PasswordExpired)
            {
                MessageBox.Show("Your password has expired. You are required to change it.");
            }
            else
            {
                MessageBox.Show("Your password is not secure enough. You are required to change it.");
            }
        }
        else
        {
            MessageBox.Show("You are required to change your password at first logon.");
        }
        VGChangePasswordForm form = new VGChangePasswordForm(runtime);
        form.UserName = currentUsername;
        form.OldPassword = currentPassword;
        if (form.ShowDialog(this) == DialogResult.OK)
        {
            currentPassword = form.NewPassword;
            goto Reauthenticate;
        }
    }
}
else
{
    this.DialogResult = DialogResult.OK;
    if (!state.IsPasswordSecured)
    {
        if (MessageBox.Show("Your password is not secure enough. " + Environment.NewLine + "Do you want to change it?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly) = DialogResult.Yes)
        {
            // Use the Visual guard form to change the password
            // You can replace it by your own form
            VGChangePasswordForm form = new VGChangePasswordForm();
            form.ShowDialog();
        }
    }
}
See Also