Copied to clipboard

Flag this post as spam?

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


  • Danny Douglass 28 posts 43 karma points
    Sep 16, 2009 @ 15:17
    Danny Douglass
    0

    Getting allowed roles for current page?

    I'm simply trying to get the roles that are associated with a document via the API.  It seems that the following call is deprecated (and returns a null object):

    Access.GetAccessingMembershipRoles(int DocumentId, string path)

    I've also tried the following library method, but it didn't seem to do the trick either:

    library.AllowedGroups(int DocumentId, string path)

    Any suggestions?  

    Thanks in advance!

  • Comment author was deleted

    Sep 16, 2009 @ 15:27

    Try this:

    API Question/Documentation

    int nodeid = //document node id
    string[] _roles = Roles.GetAllRoles();
     
                if (_roles.Length > 0)
                {
                    foreach (string role in _roles)
                    {
                               
                            if (cms.businesslogic.web.Access.IsProtectedByMembershipRole(nodeid, role))
                                // OK
                        }
                                        
                }

     

  • Danny Douglass 28 posts 43 karma points
    Sep 16, 2009 @ 15:45
    Danny Douglass
    0

    Hi Tim - thanks for the response.

    We are traversing the entire content tree building a custom sitemap navigation services and looping through for 1000s of pages (with 30 or more roles possible roles per page) would be rather arduous.  Is there no direct way to access the roles associated with a page via the API?

  • Comment author was deleted

    Sep 16, 2009 @ 16:07

    Hi Danny,

    umbraco.cms.businesslogic.web.Access.GetAccessingMembershipRoles method should be what you need.

    It returns null if the page isn't protected. And if it is protected it returns a string array with the role id's.

    Cheers,

    Tim

  • Danny Douglass 28 posts 43 karma points
    Sep 16, 2009 @ 16:20
    Danny Douglass
    0

    Thanks Tim - we will give that a shot.

  • Danny Douglass 28 posts 43 karma points
    Sep 16, 2009 @ 16:29
    Danny Douglass
    0

    I'll let Seth continue this in email - didn't realize we were duplicating responses. =] 

    I'll add the solution if we get it working.

  • Danny Douglass 28 posts 43 karma points
    Sep 16, 2009 @ 16:41
    Danny Douglass
    0

    Turns out this was a content-related issue with the null return. Tim was correct in noting that umbraco.cms.web.Access.GetAccessingMethodRoles returns all the roles of a particular page.

    Thanks for your help.

Please Sign in or register to post replies

Write your reply to:

Draft