我正在尝试做一些简单的事情(我认为)- 使用我们域中的 Active Directory 组使用基于角色的安全性来保护我的应用程序。
具体来说,我需要根据当前登录的用户是否属于 domain\groupA
来显示/隐藏页面上的项目在事件目录中。出于某种原因,很难找到有关为此使用 Active Directory 的信息。我似乎找到的所有内容都涉及使用角色使用基于表单的身份验证的详细信息,或者它使用数据库来存储信息。
我只想在 Active Directory 中使用我们已经概述的安全结构。有人可以解释一下我需要什么吗?
我需要:
-
<roleManager enabled="true"/>
在web.config
-
<allow roles ="domain\groupA"/>
在web.config
- IIS 设置为 windows 身份验证
-
if (User.IsInRole(@"domain\groupA")){ //do stuff }
在我的页面上?
我还缺少什么?任何事物?因为它不工作。呵呵。
感谢大家的帮助。
最佳答案
您可能只需要在您的 web.config 中添加一个 RoleProvider 来告诉应用程序如何针对 AD 进行搜索。
示例代码来自 here .
<roleManager defaultProvider="WindowsProvider"
enabled="true"
cacheRolesInCookie="false">
<providers>
<add
name="WindowsProvider"
type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
关于c# - 使用 Active Directory 中的安全组的 Asp.Net 基于角色的身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/209242/