[英]asp.net User.IsInRole check in whole website
im using asp.net with c#, 我在C#中使用asp.net,
I want to check whether a user is on certain active directory group. 我想检查用户是否在某些活动目录组中。
Im doing this check: 我正在执行此检查:
if (HttpContext.Current.User.IsInRole(ConfigurationSettings.AppSettings["Group"]))
{
}
The thing is: where do I place this code? 问题是:该代码放在哪里? The site has several pages and I want the validation to be on all pages.
该网站有几个页面,我希望所有页面都可以进行验证。
Do I put this on the master page? 我该放在母版页上吗?
Thanks. 谢谢。
What do you want to do if the user is not in the required role? 如果用户没有所需角色,您想怎么办? Depending on the answer to that question, you could:
根据该问题的答案,您可以:
check it in the Master page 在母版页中检查
check it in a base Page from which your Page code-behind classes derive 在基页面中检查它,您的页面代码背后的类是从基页面派生的
check it in global.asax, for example in the Application_AuthorizeRequest event handler 在global.asax中检查它,例如在Application_AuthorizeRequest事件处理程序中
... etc ... ...等等...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.