Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jonathan Roberts 372 posts 1005 karma points
    Apr 27, 2015 @ 13:55
    Jonathan Roberts
    0

    Get Page Roles

    Hi, Using c# how can I get a list of the Roles assigned to a page - I have set up Public Access roles using the CMS but not sure how I can get this list of roles into an object?

    jon

  • Ryan 34 posts 138 karma points
    Apr 28, 2015 @ 11:26
    Ryan
    0

    Hi Jonathan,

    I'm pretty sure you would have to map the roles to an object yourself, manually. I'm not sure if this will help you but I'm guessing you want to check if a member has access to a certain page. If this is the case you could approach it from a different angle...

     if (Umbraco.MemberHasAccess(content.Id, content.Path))
     {
         //Do something                                   
     }
    

    Hopefully that helps :)

  • Jonathan Roberts 372 posts 1005 karma points
    Apr 28, 2015 @ 11:30
    Jonathan Roberts
    0

    Hi, Thanks for the reply - unfortunately we don't want to check if they have access but we do need the list of Permitted user groups for that page.

  • Ryan 34 posts 138 karma points
    Apr 28, 2015 @ 11:38
    Ryan
    3

    Hi,

    This should work...

    var roles = umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles(content.Id,content.Path);
    

    Thanks!

  • Jonathan Roberts 372 posts 1005 karma points
    Apr 28, 2015 @ 14:25
    Jonathan Roberts
    0

    Perfect - that's exactly what I wanted - thanks

    Jon

  • nickornotto 317 posts 679 karma points
    Mar 20, 2019 @ 23:31
    nickornotto
    0

    What's the current alternative to GetAccessingMembershipRoles? Because umbraco 7.6 highlights umbraco.cms.businesslogic.web.Access as obsolete and tells to use IPublicAccessService

    I was unable to find out how to use it, all I got to was

    IContent content = GetById(id);
    Attempt<PublicAccessEntry> access = _publicAccessService.IsProtected(content);
    

    which doesn't have any information about the current page roles.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies