In some situations, you need to control the access to a certain page for specific users. Sitefinity CMS enables you to manage permissions through code using the Sitefinity CMS Permissions API.
When a new permission is added to a page, it is always added as a reference to all the child pages (and their child pages and so on) of that page. This reference is added no matter whether the child page inherits permissions or not. Therefore, to delete a permission, you must first remove all its references in all child pages.
You can either delete the permissions permanently from the database or just reset the permission values, so that they are not counted during security checks.
To traverse the tree and find all the inheritors of a page, you use the helper method GetPermissionsInheritors() in the PageManager class. Once the permission is removed from all the collections, you can delete the permission. Use the following code in the relevant user widget or service:
As a result, the page permissions and entries are deleted from the database.
An alternative way to remove the permission is to reset it by setting its Grant and Deny fields to 0. Once the values are reset, the permissions are no longer effective. Permissions will not appear on the UI and will not be counted on any security checks. Note, however, that using this method only resets page permissions, but does not delete them permanently from the database.
Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.
This free lesson teaches administrators, marketers, and other business professionals how to use the Integration hub service to create automated workflows between Sitefinity and other business systems.
This free lesson teaches administrators the basics about protecting yor Sitefinity instance and its sites from external threats. Configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.
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.
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important