Check and demand permissions

Checking permission is checking whether an action is granted.

Demanding permission is verifying that an action can be executed. If the user is not allowed to perform the action, an exception of type Telerik.Sitefinity.Security.SecurityDemandFailException is thrown.

Check whether permission set is supported

To check whether a permission set is supported for secured object, you use the IsPermissionSetSupported method of the secured object. 

The following example checks whether the blog permissions set is supported. First, you initialize the blogs manager. Then, you get the security root using GetSecurityRoot. Finally, you call IsPermissionSetSupported passing BlogsPermissions.Sets.Blog.SetName.

Get all active permissions

The Permissions property of the secured item contains permissions that are part of the permissions inheritance. When the inheritance is broken and then restored, Permissions is used. 

Sitefinity CMS allows you to get the permissions that are relevant to the current state of the secured object by using the GetActivePermissions extension method of ISecuredObject.

Check permissions

  • To check whether permissions are granted, you use the IsGranted method of ISecuredObject
  • To check whether permissions are denied, you use the IsDenied method of ISecuredObject
  • To demand permissions, you use the Demand method of ISecuredObject

The following example checks whether the current user can delete blogs. First, you initialize the blogs manager. Then, you get the security root using GetSecurityRoot. Finally, you call IsGranted passing the permissions set and action names.

Check whether current user can delete blogs

Sitefinity CMS allows you to check whether permissions are granted for specific user.  The following example checks whether the specified user can create and delete blogs. First, you initialize the blogs and user managers. Then, you get the security configuration and the blog permissions set. For more information, see For developers: Permissions configuration. Then, you create the bit mask by performing bitwise OR between the values of create and delete blog actions. For more information, see For developers: Permissions API. You get the blogs data provider security root. Finally, to check whether the specified user is granted the permissions, you use the IsGranted passing the permissions set name, the ID of the user and the actions mask. 

Check whether permissions are denied to a specific user

The same code can be used for checking whether permissions are denied and demanding by using IsDenied and Demand.

Sitefinity CMS also allows you to check whether permissions are granted for dynamic content. 

Check whether permissions are granted for dynamic types

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?