问题描述:

I am using the default xml sitemap provider in ASP.net 4.5, with security trimming enabled. Sometimes a node is available because "authorization" allows it, and other times it is because the "roles" allows it. How can I check the 3 conditions on why a node is available and log that or do anything else.

MSDN on IsAccessibleToUser

public void LogAccessibleReason(SiteMapNode node, HttpContext context){

if (node.IsAccessibleToUser(context))

{

//assuming a single role

if (System.Web.Security.Roles.IsUserInRole(node.Roles.ToString()))

{

Log("because role");

}

//check authentication

...???

// check windowsidentity

...???

}

}

相关阅读:
Top