The content you're reading is getting on in years
This post is on the older side and its content may be out of date.
Be sure to visit our blogs homepage for our latest news, updates and information.
We have seen what is the association between a security root and a permission, and how secured modules implement this association.
Here we will get to know how permissions are actually used in code.
At some point in your code, you will want to check if the currently logged user can do something. You do this by initiating a permission and using its CheckDemand method.
Actually, there is nothing you have to do. Sitefinity does this for you when it loads your module.
The UI commands you want to disable/hide if a user is not currently permitted to do a task are most probably in the View that displays all items. Very often this will be in a data-bound grid, so you will apply your custom logic on ItemDataBound, RowDataBound or similar events. Here is an example on how to do this (taken from the Lists module):
Here, the Hyperlink has no NavigateUrl if the user does not have CrudRights.View.
Inevitably, a question arises: since I have to Demand a permission before every CRUD operation, shouldn't I implement this in directly in the manager for this module? This depends, but the quick answer is: yes. If you implement it in the manager,
you are sure that an operation can never be performed if a user doesn't have permission. That way, the less things you have to remember, the less chance for making mistakes.
View all posts from The Progress Team on the Progress blog. Connect with us about all things application development and deployment, data integration and digital business.
Subscribe to get all the news, info and tutorials you need to build better business apps and sites
Copyright © 2019 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.