Loads the permissions of a user identified by the user name by using the specified authentication mode.

Namespace: Novalys.VisualGuard.Security
Assembly: Novalys.VisualGuard.Security (in Novalys.VisualGuard.Security.dll) Version: 2016.0.105.16 (2016.0.105.16)

Syntax

C#
public static VGAuthorizationState LoadSecurity(
	string name,
	VGAuthenticationMode mode,
	bool isAuthenticated
)
Visual Basic
Public Shared Function LoadSecurity ( 
	name As String,
	mode As VGAuthenticationMode,
	isAuthenticated As Boolean
) As VGAuthorizationState

Parameters

name
Type: System..::..String
the name of the user.
mode
Type: Novalys.VisualGuard.Security..::..VGAuthenticationMode
the authentication mode used indicating the type of the user (Database or VisualGuard).
isAuthenticated
Type: System..::..Boolean
Indicates that the given user has been authenticated.

Return Value

Type: VGAuthorizationState
A VGAuthorizationState representing the state of the authorization

Remarks

If a user has more than one role in the application, you can use the PermissionsLoading event to allow the user to select a role in the granted roles list. By default, Visual Guard will create permission set that will be a union of all permision sets granted to the roles.

Examples

Visual Basic Copy imageCopy
Dim state As VGAuthorizationState
state = VGSecurityManager.LoadSecurity ("myUserName", VGAuthenticationMode.Database, True)
If state.IsFailed Then
    If state.IsUserNotFound Then
        MessageBox.Show("Your are not declared in the security repository")
    ElseIf state.IsUserNotAuthorized Then
        MessageBox.Show("Your are not authorized to log on to this application")
    End If
Else
    Application.Run(New MDIForm)
End If
C# Copy imageCopy
VGAuthorizationState state = VGSecurityManager.LoadSecurity ("myUserName", VGAuthenticationMode.Database, true);
if (state.IsFailed)
{
    if (state.IsUserNotFound)
    {
        MessageBox.Show("Your are not declared in the security repository");
    }
    elseif (state.IsUserNotAuthorized)
    {
        MessageBox.Show("Your are not authorized to log on to this application")
    }
}
else
{
    Application.Run(new MDIForm())
}

Exceptions

ExceptionCondition
System..::..NotSupportedException

the repository does not support the specified authentication mode.

System..::..ArgumentNullException

name is null.

System..::..ArgumentException

The name is longer than 64 characters

The name is empty.

Novalys.VisualGuard.Security..::..VGConfigurationExceptionThe configuration file is not valid

or

A problem occurs during the connection to the repository.

or

The version of the repository or the version of the permissions is not supported by the application.

See Also