0

Dim currUser As String = Request.ServerVariables("LOGON_USER") を使用すると Domain\Username が返されることはわかっていますが、そのユーザーが Active Directory でどのグループに属しているかを知りたいです。

4

2 に答える 2

3

グループのリストが必要ですか? または、ユーザーが特定のグループのメンバーであるかどうかを確認しますか?

後者の場合、WindowsPrincipal.IsInRole() を使用して、ユーザーが特定のグループに属しているかどうかを確認できます。

http://msdn.microsoft.com/en-us/library/fs485fwh.aspx

たとえば、ユーザーが管理者であるかどうかを確認する場合は、次を使用できます。

If Page.User.IsInRole("BUILTIN\Administrators") Then
    ' Do something
End If
于 2009-09-10T08:36:38.943 に答える
2

UserPrincipal.GetAuthorizationGroups メソッドを使用できます

imports System.DirectoryServices.AccountManagement
dim name as string = Request.ServerVariables("LOGON_USER") 
dim user As UserPrincipal = UserPrincipal.FindByIdentity( new PrincipalContext( ContextType.Domain ), name)
dim groups As PrincipalSearchResult(Of Principal)= user.GetAuthorizationGroups()
于 2009-09-10T08:38:25.830 に答える