当前位置: 动力学知识库 > 问答 > 编程问答 >

.net - How determine why an ASP.Net node IsAccessibleToUser

问题描述:

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

...???

}

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: