Web 应用程序 Active Directory 用户角色与 User.IsInRole

发布于 2024-12-17 16:11:18 字数 230 浏览 1 评论 0原文

我需要一些建议。 我正在扩展一个 Web 应用程序以与 AD 成员角色集成,但不太确定是否可以依赖 User.IsInRole 来获取成员角色信息。初步测试表明确实如此,但是使用它与编写一个类以使用 DirectorySearcher/AccountManagement 返回用户角色之间有什么区别?

一种解决方案比另一种更好吗?

在我看来,在这种情况下它似乎达到了同样的效果。我说得对吗?

谢谢。

I need a bit of advice.
I'm extending a web app to integrate with AD member roles, and not too sure whether i can rely on User.IsInRole to have the member role information. Initial tests show me it does, but what is the difference between using this, and writing a class to return the user roles with DirectorySearcher/AccountManagement for example?

Is one solution better than the other?

It looks to me as though it achieves the same thing in this case. Am i right?

Thanks.

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

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

发布评论

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

评论(2

尸血腥色 2024-12-24 16:11:18

如果您使用活动目录授权 Users.IsInRole 检查用户是否是给定组的成员。它与检查用户所属的组并不完全相同,因为这仅提供直接成员资格。 Users.IsInRole 还会检查嵌套组成员身份。示例:

  • UserAGroupA 的成员
  • GroupAGroupB 的成员

现在,如果您检查直接成员资格对于UserA,您只会获得GroupA。但由于嵌套,Users.IsInRole 将指示 UserAGroupB 的成员。

If you use active directory authorization Users.IsInRole checks if the user is member of the given group. It is not exactly the same as checking the groups that the user belongs to, because that only gives the direct memberships. Users.IsInRole also checks nested group membership. An example:

  • UserA is a member of GroupA
  • GroupA is a member of GroupB

Now if you check the direct memberships of UserA you will only get GroupA. But Users.IsInRole will indicate that UserA is a member of GroupB thanks to the nesting.

一生独一 2024-12-24 16:11:18

只需使用 Users.IsInRole。不要让事情变得更加困难。这就是它的用途。

Just use Users.IsInRole. Don't make things harder on yourself. This is what it's for.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文