Creating a new role
[C#]
using CMS.SiteProvider;
// Create new RoleInfo RoleInfo role = new RoleInfo();
// Set RoleInfo properties except RoleID role.RoleName = "DocumentEditor"; role.DisplayName = "Document editor"; role.Description = "some description..."; role.SiteID = CMS.CMSHelper.CMSContext.CurrentSiteID;
// check if the role name is unique in the given site if (!CMS.SiteProvider.RoleInfoProvider.RoleExists(role.RoleName, CMS.CMSHelper.CMSContext.CurrentSiteName)) { // Insert new RoleInfo for current site CMS.SiteProvider.RoleInfoProvider.SetRoleInfo(role); } else { // Role with the same name already exists in specified site } |
Selecting and updating a role
[C#]
using CMS.SiteProvider;
// Get role of specified name from current site RoleInfo role = CMS.SiteProvider.RoleInfoProvider.GetRoleInfo("ArticleEditor", CMS.CMSHelper.CMSContext.CurrentSiteName);
if (role != null) { // Make some changes role.Description = "Changed description."; // Update the role CMS.SiteProvider.RoleInfoProvider.SetRoleInfo(role); } |
Deleting a role
[C#]
// Delete the role CMS.SiteProvider.RoleInfoProvider.DeleteRole("ArticleEditor", CMS.CMSHelper.CMSContext.CurrentSiteName); |
Page url: http://devnet.kentico.com/docs/devguide/index.html?managing_roles.htm