+1-888-365-2779
Try Now
More in this section

Forums / Security / Setting and Getting Global Permissions

Setting and Getting Global Permissions

2 posts, 0 answered
  1. John
    John avatar
    1 posts
    Registered:
    21 Feb 2009
    12 Oct 2009
    Link to this post
    Anyone have any idea how to set and get global permissions?

    I need to set the CmsAccess Global permission in code.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    13 Oct 2009
    Link to this post
    Hi John,

    Thank you for using our services.

    You can use the following line to check if the current logged in user has cmsAccess permissions:
    Telerik.Cms.Security.GlobalPermission permission = new Telerik.Cms.Security.GlobalPermission(Telerik.Cms.Security.GlobalRights.CmsAccess);
    bool haspermission = permission.CheckDemand();

    Then you can set permissions for a certain role using the following code:
    //get permissions for role
    ApplicationPermission perm = GlobalPermissions.Instance.GetPermission(UserManager.Default.RoleProvider.Name, "role");
    //make union of old permissions, and new permissions and set them
    perm.Union(new GlobalPermission(GlobalRights.CmsAccess));
    GlobalPermissions.Instance.SetPermissions(perm.Grant, perm.Deny, UserManager.Default.RoleProvider.Name, "role");

    Please note that if you do not make a union of the old and the new permissions, you will loose permissions that you do not wish to modify also.

    Best wishes,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered