Iterate and List Members of an NT Group with LDAP

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I posted this in VB without a response and in ADSI with no response. C#
code is fine, if someone could help it would be much appreciated.

I can get a list of Groups from my Active Directory, now I want to get a
list of all members of a group. Does anyone have code or can point me in
the direction to set the filter or do a search for this? In one drop down
list I have all the groups in the LDAP directory for our OU, I want to
select the group from the list and have the second list box list the member
name and email address. I have been searching online and have some
examples, but none are working. When I get to this line

Dim gpMemberEntry As New DirectoryEntry("LDAP://"; & memberColl)

I get this error:
The value provided for adsObject does not implement IADs.

Here is the memberColl value I am passing in (I stripped out the user data)
"CN=[UserLastName]\, [User FirstName],OU=Users,OU=[Local
OU],DC=[Domain],DC=net"

Thanks for the help.


John
Here is the last code I tried
Public Sub GetGroupMembers(ByVal strGroup As String)
Try

Dim ent As New DirectoryEntry("LDAP://[server
name]/ou=groups,ou=ogden,DC=[domain],DC=net")

Dim srch As New DirectorySearcher("(CN=" + strGroup + ")")

Dim results As SearchResultCollection = srch.FindAll()

For Each rs As SearchResult In results

Dim resultPropColl As ResultPropertyCollection = rs.Properties

For Each memberColl As Object In resultPropColl("member")

Dim gpMemberEntry As New DirectoryEntry("LDAP://"; & memberColl) --This is
the line that gives me an error

Dim userProps As System.DirectoryServices.PropertyCollection =
gpMemberEntry.Properties

Dim obVal As Object = userProps("name").Value

Dim obMail As Object = userProps("mail").Value

If obVal IsNot Nothing Then

ListBox2.Items.Add(obVal.ToString & " -- " & obMail.ToString)

End If

Next

Next

Catch ex As Exception

Trace.Write(ex.Message)

End Try

End Sub




.



Relevant Pages

  • Re: Iterate and List Members of an NT Group with LDAP
    ... C# Asynchronous Multi-Threaded Active Directory User/Group Browser ... Here is the memberColl value I am passing in (I stripped out the user ... Dim resultPropColl As ResultPropertyCollection = rs.Properties ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Iterate and List Members of an NT Group with LDAP
    ... C# Asynchronous Multi-Threaded Active Directory User/Group Browser ... Here is the memberColl value I am passing in (I stripped out the user ... Dim resultPropColl As ResultPropertyCollection = rs.Properties ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Code Stops Due to No Values In Query
    ... Dim PoseidonHotelProgram As Database ... Title = "DEPARTURES PENDING" ' Define title. ... Response = MsgBox ... Set Myset2 = db1.OpenRecordset("RESPEL ALL CHARGES") ...
    (microsoft.public.access.modulesdaovba)
  • Re: "/decompile /recompile"
    ... Response As Integer) ... 'Undo the combo-box before updating control value to "NewData" ... Dim ctl As Control ... Set rstShipVia = MyDB.OpenRecordset ...
    (comp.databases.ms-access)
  • Re: Requerying ComboBox in NotInList event
    ... Response As Integer) ... Dim rst As Recordset ... Set rst = CurrentDb.OpenRecordset ... Dim lngBlankFound As Long ...
    (comp.databases.ms-access)