Posted
on Jan 3, 2012
(permalink)
Hi,
I have a problem when trying to get the pages for a specific user role.
I have 4 types of roles and more than 13 pages in total, on a basic hierarchy with 2 levels. These are the pages for my main navigation and I want it to be different fr every user role.
I want to use this from outside the Sitefinity app, so I make use of the role's name, like this:
ArrayList listOfRoles = new ArrayList();
var siteNode = App.WorkWith().Pages().Get().Where(p => p.Parent == null && p.Title == "Pages").Single();
listOfRoles.Add(SecurityManager.GetRoleId("AppRoles", "Everyone"));
listOfRoles.Add(SecurityManager.GetRoleId("AppRoles", "MyRoleHere"));
Guid[] listOfRolesGuids = new Guid[listOfRoles.Count];
listOfRolesGuids = listOfRoles.ToArray(typeof(Guid)) as Guid[];
SecurityConfig cfg = Config.Get<SecurityConfig>();
var permSet = cfg.Permissions[SecurityConstants.Sets.Pages.SetName];
int actionMask = permSet.Actions[SecurityConstants.Sets.Pages.View].Value;
var firstLevelPages = App.WorkWith().Pages().LocatedIn(Telerik.Sitefinity.Fluent.Pages.PageLocation.Frontend).
ThatArePublished()
.ThatBelongTo(siteNode.Id)
.Where(p => p.ShowInNavigation == true)
.Where(p => p.IsGranted(SecurityConstants.Sets.Pages.SetName, listOfRolesGuids, actionMask))
.OrderBy(p => p.Ordinal)
.Get().ToList();
Somehow, I end up with 2 different results, one when I am logged in as an admin, the other when I'm not.
Is there a way to bypass this? I would like to get the pages regardless of the cookies on my browser.
Any help or hint will be greatly appreciated, thanks.