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
}
|