tags:

views:

40

answers:

2

Hi

I notice you have an example code of listing groups Ad computer Accounts are a member of in c#, do you have an example in vb ?

Cheers

Andy

A: 

not really related to AD, but in most cases you can use Reflector to translate C# to VB.NET (& vice versa), just create a compilable dll with your code and dissamble it with Reflector in VB.NET code.

najmeddine
A: 

You could use 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
Darin Dimitrov