Skip to main content
.NET 6.0+

SecuritySystem.CustomIsGranted Event

Occurs when the PermissionRequest instance is passed to the SecuritySystem.IsGranted method.

Namespace: DevExpress.ExpressApp

Assembly: DevExpress.ExpressApp.v24.1.dll

NuGet Package: DevExpress.ExpressApp

Declaration

public static event EventHandler<CustomHasPermissionToEventArgs> CustomIsGranted

Event Data

The CustomIsGranted event's data class is CustomHasPermissionToEventArgs. The following properties provide information specific to this event:

Property Description
Handled Gets or sets a value that indicates whether the event handler has completely handled the event or whether the system should continue its own processing. Inherited from HandledEventArgs.
MemberName Specifies the name of the target object’s member.
ObjectSpace Specifies the Object Space used to process the request.
ObjectType Specifies the target object type.
Operation Specifies the name of the requested operation. Valid operation names are declared as the SecurityOperations class’ constants.
Result Specifies whether or not the permission is granted to the current user.
TargetObject Specifies the target object.

Remarks

Handle this event to provide a custom code that calculates the IsGranted result. To override the default code, set the Handled to true and assign a custom result to the CustomHasPermissionToEventArgs.Result parameter.

SecuritySystem.CustomIsGranted += delegate (object sender, CustomHasPermissionToEventArgs e) {
    if (e.Operation == SecurityOperations.Write ||
        e.Operation == SecurityOperations.Delete ||
        e.Operation == SecurityOperations.Create) {
        e.Result = false;
        e.Handled = true;
    }
};

As the CustomIsGranted event is static, you can subscribe to it from any place in your code which is executed before a user is logged on, e.g.:

  • in the constructor of your platform-agnostic module located in the Module.cs (Module.vb) file;
  • in the constructor of your application located in the WinApplication.cs (WinApplication.vb) or WebApplication.cs (WebApplication.vb) file;
  • in the Main method of the WinForms application located in the Program.cs (Program.vb) file, before the WinApplication.Start call;
  • in the Application_Start method of the ASP.NET Web Forms application located in the Global.asax.cs (Global.asax.vb) file, before the WebApplication.Start call.

The CustomIsGranted event is not raised when:

  • evaluating a navigation permission specified via the Role’s Navigation Permissions tab;
  • filtering data at the ORM level or at the application server side (in the Integrated or Middle-Tier security mode);
  • calling the SecuritySystem.Instance.IsGranted method instead of SecuritySystem.IsGranted;
  • passing the custom IPermissionRequest request object which does not inherit PermissionRequest to the IsGranted method.
See Also