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) };
