【问题标题】:Asp.Net Role-based authentication using Security groups in Active Directory使用 Active Directory 中的安全组的 Asp.Net 基于角色的身份验证
【发布时间】:2010-09-17 13:52:22
【问题描述】:

我正在尝试做一些简单的事情(我认为) - 使用我们域中的 Active Directory 组使用基于角色的安全性来保护我的应用程序。

具体来说,我需要根据当前登录的用户是否是 Active Directory 中 domain\groupA 的一部分来显示/隐藏页面上的项目。出于某种原因,很难找到有关为此使用 Active Directory 的信息。我似乎找到的所有内容都详细介绍了使用角色使用基于表单的身份验证,或者它使用数据库来存储信息。

我想要做的就是在我们的 Active Directory 中使用我们已经概述的安全结构。有人可以解释一下我需要什么吗?

我需要吗:

  1. <roleManager enabled="true"/>web.config
  2. <allow roles ="domain\groupA"/>web.config
  3. IIS 设置为 Windows 身份验证
  4. if (User.IsInRole(@"domain\groupA")){ //do stuff } 在我的页面中?

我还缺少什么?任何事物?因为它不工作。呵呵。

感谢大家的帮助。

【问题讨论】:

    标签: c# asp.net security authentication role


    【解决方案1】:

    您可能只需要在 web.config 中添加一个 RoleProvider 来告诉应用如何针对 AD 进行搜索。

    来自here的示例代码。

    <roleManager defaultProvider="WindowsProvider" 
      enabled="true"
      cacheRolesInCookie="false">
      <providers>
        <add
          name="WindowsProvider"
          type="System.Web.Security.WindowsTokenRoleProvider" />
      </providers>
    </roleManager>
    

    【讨论】:

      猜你喜欢
      • 2021-12-09
      • 1970-01-01
      • 2015-03-20
      • 1970-01-01
      • 2019-10-04
      • 2016-03-07
      • 2018-09-06
      • 1970-01-01
      • 2014-05-23
      相关资源
      最近更新 更多