Visual Guard Class Library Documentation

VGSecurityManager.VGPermissionsLoadingEventHandler Event

Occurs before the permissions are loaded and allows filtering the list of user's roles.

public static event VGPermissionsLoadingEventHandler PermissionsLoading;

Event Data

The event handler receives an argument of type VGPermissionsLoadingEventArgs containing data related to this event. The following VGPermissionsLoadingEventArgs properties provide information specific to this event.

Property Description
Identity Gets the IIdentity representing the user for which the permission will be loaded.
RepositoryId Gets the Visual Guard Repository Id of the user for which the permission will be loaded.
Roles Gets or sets the list of VGGrantedRole corresponding to roles granted to the user.
Status Gets or sets the VGAuthorizationStatus representing the status of the current authorization process.

Remarks

The event handler receives an argument of type VGPermissionsLoadingEventArgs containing data related to this event. The PermissionsLoading event allows a user to filter the list of roles granted to the principal or to cancel the authorization (or authentication) process.

Example

This example display how to use the event PermissionsLoading to allow the user select a roles in the list of granted roles.

[Visual Basic]
Private Sub OnPermissionLoading(ByVal sender As Object, ByVal e As VGPermissionsLoadingEventArgs)
    If e.Roles.Length > 0 Then
        Dim form As New SelectRoleForm
        form.Roles = e.Roles
        If form.ShowDialog() = DialogResult.OK Then
            e.Roles = form.Roles
        Else
            e.Cancel = True
        End If
    End If
End Sub
[C#]
private void OnPermissionLoading (object sender, VGPermissionsLoadingEventArgs args)
{
    if (e.Roles.Length > 0)
        SelectRoleForm form = new SelectRoleForm()
        form.Roles = e.Roles
        if (form.ShowDialog() == DialogResult.OK)
        {
            e.Roles = form.Roles
        }
        else
        {
            e.Cancel = true
        }
    }
}

See Also

VGSecurityManager Class | Novalys.VisualGuard.Security Namespace