Everything SharePoint and XAML

My continuous learning of SharePoint, XAML, Silverlight, Windows Phone 7, Windows 8, Office, VSTO, C#…

PortalSiteMapProvider and CAS

Posted by Steve Pietrek on February 18, 2008

Today I was looking to roll my own site map. Nothing special – just wanted to display the content in a SPTreeView. The code is fairly basic:

...
PortalSiteMapProvider portalSiteMap = new PortalSiteMapProvider();
portalSiteMap.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
portalSiteMap.IncludeHeadings = false;
portalSiteMap.EncodeOutput = true;
...

The problem was when I ran the code, the site would not come back (well one time I waited long enough until it timed out). I also noticed the DW20.exe process was running – not good.

After digging around, I soon realized my nodes, at least node[0] had errors.

An error occured while rendering navigation for requested URL: /SITES/INTRANET. Exception message: Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' failed. Stack trace:    at Microsoft.SharePoint.SPSite..ctor(String requestUrl, SPUserToken userToken)
   at Microsoft.SharePoint.Publishing.CachedObjectFactory.CreatePageFromUrl(String url, SPWeb contextWeb)
   at Microsoft.SharePoint.Publishing.CachedArea.get_Audience()
   at Microsoft.SharePoint.Publishing.Navigation.CachedObjectSiteMapNode..ctor(PortalSiteMapProvider provider, CachedArea cachedArea)
   at Microsoft.SharePoint.Publishing.Navigation.PortalWebSiteMapNode..ctor(PortalSiteMapProvider provider, CachedArea cachedArea)
   at Microsoft.SharePoint.Publishing.CachedArea.CreateSiteMapNode(PortalSiteMapProvider provider, PortalWebSiteMapNode webNode)
   at Microsoft.SharePoint.Publishing.CachedObject.GetNavigationNode(PortalSiteMapProvider provider, PortalWebSiteMapNode webNode, Boolean useCache)
   at Microsoft.SharePoint.Publishing.CachedObject.GetNavigationNode(PortalSiteMapProvider provider)
   at Microsoft.SharePoint.Publishing.Navigation.ProxySiteMapNode.get_ReferencedNode()
   at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedTypes, NodeTypes includedHiddenTypes, OrderingMethod ordering, AutomaticSortingMethod method, Boolean ascending, Int32 lcid)
   at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedHiddenTypes)
   at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.GetChildNodes(PortalSiteMapNode node, NodeTypes includedHiddenTypes)

Then I get a BUNCH (at least until I kill the process) of these errors in the logs:

PortalSiteMapProvider was unable to fetch children for node at URL: /SITES/INTRANET, message: Object reference not set to an instance of an object., stack trace: at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapNode.GetNavigationChildren(NodeTypes includedHiddenTypes) at Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapProvider.GetChildNodes(PortalSiteMapNode node, NodeTypes includedHiddenTypes)

The problem was I did not have the correct permissions. Temporarily giving the site Full trust solved the issue. Need to review the CAS but the SharePointPermission class had already been added and it does not work. Sigh!

Advertisements

2 Responses to “PortalSiteMapProvider and CAS”

  1. CI said

    Steve, were you ever able to resolve this problem? I’m running into the same problem and am pulling my hair out trying to solve it.

    Thx!

  2. Ted Assur said

    I’m running into the exact scenario. I cannot find a CAS permission that will allow this to work!! I’m trying to follow best practice on security and limit permissions via CAS, but only Full trust will allow this item that I’ve found. I’d love to see if anyone else has got this working.

Sorry, the comment form is closed at this time.

 
%d bloggers like this: