简体   繁体   English

asp.net User.IsInRole检查整个网站

[英]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.

相关问题 ASP.NET User.IsInRole 说明 - ASP.NET User.IsInRole clarification 如何在 ASP.NET Core 中自定义/覆盖 User.IsInRole - How to custom/override User.IsInRole in ASP.NET Core 在ASP.NET Core中重写User.IsInRole - Override User.IsInRole in ASP.NET Core ASP.NET活动目录身份验证User.IsInRole - ASP.NET active directory authentication User.IsInRole asp.net mvc 3 User.IsInRole(“管理员”) - asp.net mvc 3 User.IsInRole(“Admin”) ASP.NET核心自定义基于角色的授权(Custom User.IsInRole)? - ASP.NET Core Custom Role Based Authorization (Custom User.IsInRole)? 需要帮助以Asp.Net身份1运行[Authorize(Roles =“ Admin”)]和User.isInRole(“ Admin”) - Need help getting [Authorize(Roles=“Admin”)] and User.isInRole(“Admin”) working in Asp.Net identity 1 ASP.NET成员资格 - 使用哪个RoleProvider User.IsInRole()检查ActiveDirectory组? - ASP.NET Membership - Which RoleProvider to use so User.IsInRole() checks ActiveDirectory Groups? ASP.NET / VB.NET 检查是否有(不同的)用户 IsInRole - ASP.NET / VB.NET Check If a (different) User IsInRole ASP.NET Identity 2.0检查当前用户是否处于角色IsInRole中 - ASP.NET Identity 2.0 check if current user is in role IsInRole
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM