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

Forums / Developing with Sitefinity / Permissions and Authenticated users

Permissions and Authenticated users

3 posts, 0 answered
  1. David
    David avatar
    38 posts
    Registered:
    05 Apr 2012
    31 Oct 2013
    Link to this post
    Hi

    I am trying to set permissions on a page via the Sitefinity API. I have followed Boyan Barnev's excellent blog post at http://www.sitefinity.com/blogs/boyan-barnevs-blog-/2013/06/19/working-with-sitefinity-permissions-api---managing-permissions which has allowed me to add a permission.

    The end point is to have the page only able to be viewed by a specific role. The page is possibly inheriting the permission allowing Authenticated users to view the page. When I view the permissions after running my code, I see Authenticated users and the role I added have view permission. I would like to deny or revoke or remove this permission as it is not required.

    The line I use to add the new permission is
    perm.GrantActions(false, new string[] { SecurityConstants.Sets.Pages.View });
    where perm is a Permission.

    I thought the first parameter (Append), when set to false, would replace any existing permissions or is this incorrect?

    All the examples use the ID of the objects involved. I can't seem to find out how to get the id of the "Authenticated" role, or is there something else I need to look for?

    Thanks,
    David
  2. Atanas Valchev
    Atanas Valchev avatar
    414 posts
    Registered:
    04 Jan 2016
    05 Nov 2013
    Link to this post
    Hello David,

    Thank you for contacting us.

    To use the context of Boyan's sample, you can just change the user, to a role by getting the role manager for AppRoles and then getting the Authenticated role:

    var rolemanager = RoleManager.GetManager("AppRoles");
                 
    var user = rolemanager.GetRole("Authenticated");
     
    And the sample will be applied for the role instead of the user.


    Regards,
    Atanas Valchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. David
    David avatar
    38 posts
    Registered:
    05 Apr 2012
    07 Nov 2013 in reply to Atanas Valchev
    Link to this post

    Hi Atanas

    Thanks for your reply on how to get the Authenticated role.

    The solution to the problem of clearing permissions for a clean slate, is to call .Clear() on the permissions collection, for future reference. Once this is done, it is possible to add whatever permissions are required.

    Thanks,

    David

3 posts, 0 answered