使用 Active Directory 中的安全组进行 Asp.Net 基于角色的身份验证

发布于 2024-07-08 11:24:35 字数 739 浏览 9 评论 0 原文

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

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

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

我是否需要:

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

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

感谢你的帮助。

I am attempting to do something simple (I thought) - securing my application using roles-based security using Active Directory groups in our Domain.

Specifically, I need to show/hide items on a page depending upon whether the currently logged in user is part of domain\groupA in Active Directory. For some reason, it is difficult finding information on using Active Directory for this. Everything I seem to find goes into details of using forms-based authentication using roles, or it uses a DB to store the information.

All I want to do is use our already outlined security structure in our Active Directory. Can someone please explain what I need?

Do I need:

  1. <roleManager enabled="true"/> in web.config
  2. <allow roles ="domain\groupA"/> in web.config
  3. IIS set to windows authentication
  4. if (User.IsInRole(@"domain\groupA")){ //do stuff } in my page?

What else am I missing? Anything? 'cause its not working. heh.

Thanks all for your help.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

街角卖回忆 2024-07-15 11:24:36

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

来自此处的示例代码。

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

You probably just need to add a RoleProvider to your web.config to tell the app how to do searches against AD.

Sample code from here.

<roleManager defaultProvider="WindowsProvider" 
  enabled="true"
  cacheRolesInCookie="false">
  <providers>
    <add
      name="WindowsProvider"
      type="System.Web.Security.WindowsTokenRoleProvider" />
  </providers>
</roleManager>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文