Security Trim SPNavigationNode

SharePoint Short #3
To have the URL specified by a SPNavigationNode security trimmed, make sure you do not specify the isExternal constructor parameter.

Obviously, specifying true for this parameter would not apply security trimming against the link, as you would be adding an external link. Specifying false, you’d think it would. Think again.

Using the two parameter constructor does apply security trimming, where relevant.

So, instead of

SPNavigationNode newNavNode = new SPNavigationNode("Node name",
                                  "http://someurl/library/page.aspx", false);

do

SPNavigationNode newNavNode = new SPNavigationNode("Node name",
                                  "http://someurl/library/page.aspx");
This entry was posted in SharePoint Shorts and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

Solve the maths problem shown below before posting: *