使用 VB.NET 检测 Windows 用户所在的域用户组
我知道使用 Dim currUser As String = Request.ServerVariables("LOGON_USER") 返回域\用户名,但我想知道该用户在 Active Directory 中属于哪个组。
I know that using Dim currUser As String = Request.ServerVariables("LOGON_USER") returns the Domain\Username, but I want to know what Group that user is in say in Active Directory.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您想要群组列表吗?或者您想检查用户是否是特定组的成员?
如果是后者,您可以使用 WindowsPrincipal.IsInRole() 检查用户是否属于特定组:
http://msdn.microsoft.com/en-us/library/fs485fwh.aspx
例如,如果您想检查用户是否是管理员,您可以使用:
Do you want a list of the groups? Or do you want to check if the user is a member of a specific group?
If the latter, you can use WindowsPrincipal.IsInRole() to check if the user belongs to a specific group:
http://msdn.microsoft.com/en-us/library/fs485fwh.aspx
For example, if you want to check if the user is an Administrator you can use:
您可以使用 UserPrincipal.GetAuthorizationGroups 方法
You can use UserPrincipal.GetAuthorizationGroups Method