J
John Wright
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
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