Forums

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Security > Check page permission for a specific role from code

Check page permission for a specific role from code

  • Posted on Feb 15, 2010 (permalink)

    Hallo Telerik Team,

    I would like to check a page permission for a specific role (not the current User roles) from code, 

    PagePermission.CheckDemand(PageRights) functions only with the current User Roles

    thank you

    Guyso

    Reply

  • Radoslav Georgiev Radoslav Georgiev admin's avatar

    Posted on Feb 15, 2010 (permalink)

    Hello Guyso,

    You can use the SecurityManager and cast the ICmsPage to ISecured object. Then you can get all permissions and using logical operations check for particular permissions:
    //get permsissions for secured object for all roles in default provider
    IList permissions = cmsManager.SecurityManager.GetPermissions((ISecured)page);
    foreach (Permission permission in permissions)
    {
        int grant = permission.Grant;
        grant |= PageRights.Delete;
        if (permission.Grant == grant)
        {
     
        }
    }
    //get permission for particlular role from particular provider
    IAccessPermisson accessPermission = cmsManager.SecurityManager.GetPermission((ISecured)page, "Sitefinity", "test");
    int deny = accessPermission.Deny;
    deny |= PageRights.View;
    if (accessPermission.Deny == deny)
    {
        //means that the View permission is set to deny for this role for particular page
    }

    Kind regards,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.

    Reply

Skip Navigation LinksHome / Developer Network / Forums / Sitefinity Older Versions (3.x): Security > Check page permission for a specific role from code