Web 应用程序 Active Directory 用户角色与 User.IsInRole
我需要一些建议。 我正在扩展一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用活动目录授权
Users.IsInRole
检查用户是否是给定组的成员。它与检查用户所属的组并不完全相同,因为这仅提供直接成员资格。Users.IsInRole
还会检查嵌套组成员身份。示例:UserA
是GroupA
的成员GroupA
是GroupB
的成员现在,如果您检查直接成员资格对于
UserA
,您只会获得GroupA
。但由于嵌套,Users.IsInRole
将指示UserA
是GroupB
的成员。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 ofGroupA
GroupA
is a member ofGroupB
Now if you check the direct memberships of
UserA
you will only getGroupA
. ButUsers.IsInRole
will indicate thatUserA
is a member ofGroupB
thanks to the nesting.只需使用 Users.IsInRole。不要让事情变得更加困难。这就是它的用途。
Just use Users.IsInRole. Don't make things harder on yourself. This is what it's for.