Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am working on a project which allows the use of SharePoint 2010 as a content management source but will publish out to another web app. There are a number of reasons for this that I'm not going to cover just now.

My main issue at the moment though is that whilst iterating through the SiteMapNodeCollection obtained as below and then check each node whether its accessible or not, the result is always "true".

I've even tried creating a new HTTP Context so that my user account wasnt used, however the result is that the nodes are always accessible (even when anonymous access is disabled).

How do I get the correct value - i.e. False when the page is not anonymously accessible, true when it is?

Get the Nodes

PortalSiteMapProvider map = PortalSiteMapProvider.GlobalNavSiteMapProvider;
var nodes = map.RootNode.ChildNodes;

check the nodes accessibility

var myContext = HttpContext.Current;
HttpRequest httpRequest = Node.Url.StartsWith("/") ? new HttpRequest(Node.Title,     SPContext.Current.Site.Url +Node.Url, string.Empty) : new HttpRequest(Node.Title, Node.Url, string.Empty);
var httpResponse = new HttpResponse(TextWriter.Null);
var testContext = new HttpContext(httpRequest, httpResponse);

NavigationItem navItem = new NavigationItem { Title = Node.Title, Url = Node.Url, Secured = Node.IsAccessibleToUser(testContext) };
share|improve this question
    
Did you find the answer to this? If yes, could you post the answer? –  Kit Menke Jul 29 '11 at 16:39
add comment

1 Answer

Make sure that the system.web -> SiteMap -> Provider attribute SecurityTrimmingEnabled is set to 'true' in your web.config file?

See MSDN article on ASP.NET security trimming for more information.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.