列表组计算机帐户是ASP.Net VB的成员

时间:2009-11-12 10:59:09

标签: vb.net

我注意到你有一个列出组的示例代码广告计算机帐户是c#的成员,你在vb中有一个例子吗?

干杯

安迪

2 个答案:

答案 0 :(得分:0)

与AD无关,但在大多数情况下,您可以使用Reflector将C#转换为VB.NET(反之亦然),只需使用您的代码创建一个可编译的dll,并使用VB.NET代码中的Reflector对其进行消隐。

答案 1 :(得分:0)

您可以使用PrincipalContext

Imports System.DirectoryServices.AccountManagement

Module Module1

    Sub Main()
        Using ctx As New PrincipalContext(ContextType.Domain)
            Using p = Principal.FindByIdentity(ctx, "your_account_name")
                If Not p Is Nothing Then
                    Dim groups = p.GetGroups()
                    Using groups
                        For Each group In groups
                            Console.WriteLine("{0} - {1}", group.SamAccountName, group.DisplayName)
                        Next
                    End Using
                End If
            End Using
        End Using
    End Sub
End Module
相关问题