Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / March 2008

Tip: Looking for answers? Try searching our database.

Iterate and List Members of an NT Group with LDAP

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Wright - 11 Mar 2008 17:17 GMT
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
pipo - 11 Mar 2008 18:11 GMT
Hope this will help you:
Howto: (Almost) Everything In Active Directory via C#
http://www.codeproject.com/KB/system/everythingInAD.aspx#42

C# Asynchronous Multi-Threaded Active Directory User/Group Browser
http://www.c-sharpcorner.com/UploadFile/rmcochran/async_ad09302007093117AM/async
_ad.aspx


>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.
[quoted text clipped - 65 lines]
>
> End Sub
John Wright - 12 Mar 2008 14:26 GMT
Thanks for the links, but neither of them do what I need.  I'll keep
looking.

John

> Hope this will help you:
> Howto: (Almost) Everything In Active Directory via C#
[quoted text clipped - 73 lines]
>>
>> End Sub

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.