Enumerate members of a group

united1

New member
Joined
May 9, 2007
Messages
1
Programming Experience
1-3
Hi Guys,

I am trying to enumerate the members of the administrator group to display as below in a listbox

builtin\adminstrator
builtin\guest
domainnamehere\blah.blah
domainnamehere\blah2.blah2
differentdomain\blah.blah

at the moment all i can get is:

administrator
guest
blah.blah
blah2.blah2
blah.blah

Here is the code i'm using, i realise this is the long way to go about this process.

VB.NET:
Dim localMachine As DirectoryEntry = New DirectoryEntry("WinNT://" + Environment.MachineName)
        Dim admGroup As DirectoryEntry = localMachine.Children.Find("administrators", "group")
        Dim members As Object = admGroup.Invoke("members", Nothing)
        For Each groupMember As Object In CType(members, IEnumerable)

            Dim member As DirectoryEntry = New DirectoryEntry(groupMember)
            lstAdmin.Items.Add(member.name, 0)
 
Back
Top