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):
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?
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.
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
Try this:
API Question/Documentation
string[] _roles = Roles.GetAllRoles();
{
foreach (string role in _roles)
{
if (cms.businesslogic.web.Access.IsProtectedByMembershipRole(nodeid, role))
// OK
}
}
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
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
Thanks Tim - we will give that a shot.
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.
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.
is working on a reply...