IMPORTANT: This version of Sitefinity CMS is out of support and the respective product documentation is no longer maintained and can be outdated. Use the version selector to view a supported product version.
To manage roles, use the Telerik.Sitefinity.Security.RoleManager class. You can get an instance of the manager with the default roles data provider. However, this will not work with the out-of-the-box roles, such as Administrators, Editors, Authors, because they are coming from the AppRoles provider. So you must get an instance of the provider by passing the SecurityManager.ApplicationRolesProviderName as a parameter:
For more information, see For developers: Roles data providers.
The following example creates a role. First, you get an instance of the roles manager. Then, you create the role by calling the CreateRole method of the manager. Finally, you save the changes.
You can query a role by:
Querying a role by ID
The following example queries for a role by its ID. First, you get an instance of the roles manager. Then, you get all roles by calling the GetRoles method of the manager and filter based on the ID property.
Querying a role by name
The following example queries for a role by its name. First, you get an instance of the roles manager. Then, you get all roles by calling the GetRoles method of the manager and filter based on the Name property.
Querying all roles
The following example queries for all roles First, you get an instance of the roles manager. Then, you get all roles by calling the GetRoles method of the manager.
The following example modifies a role by changing its name. To modify a role, you get an instance of the role. In this example, you get in instance of the role by its ID. For more information, see Query roles above. Then, you change the name and, finally, you save the changes.
The following example deletes a role. To delete a role, you get an instance of the role. In this example, you get an instance of the role by its ID. For more information, see Query roles above. Then, you delete the role by calling the Delete method of the manager and passing the role as an argument. Finally, you save the changes.
Back To Top
To submit feedback, please update your cookie settings and allow the usage of Functional cookies.
Your feedback about this content is important