Last post Feb 14, 2006 11:16 AM by dunnry
Jan 25, 2006 04:55 PM|Shadow08029|LINK
I am trying to find a way to query active directory to get the email addresses of the users that belong to a given group.
I was able to do it with the code I included below, but I am looking for a more direct approach.
The code below has to 1st query AD to get the users in a given group. Then if that query returned, say 10 people, I would then need to query AD 10 more times (one for each user) to get each users email.
What I am looking for is 1 query that will get all the users in a group along with their emails. Any help someone can provided would be greatly appreciated.
Dim sResultInfo As
String = ""
Dim ent As DirectoryEntry
Dim srch As DirectorySearcher
Dim ent2 As DirectoryEntry
Dim srch2 As DirectorySearcher
ent = New DirectoryEntry(LDAP://domain, DC=org, CN=Users)
srch = New DirectorySearcher("(CN=Test-929MailTest)")
As SearchResultCollection = srch.FindAll()
Dim rs As SearchResult
For Each rs
As ResultPropertyCollection = rs.Properties
For Each memberColl
nStartLocation = InStr(memberColl, "CN")
nStopLocation = InStr(nStartLocation, memberColl, ",")
sUserName = Mid(memberColl, nStartLocation, nStopLocation - nStartLocation)
lblErrorMessage.Text = sResultInfo
lblErrorMessage.Text = ex.Message
Feb 02, 2006 01:02 PM|dunnry|LINK
Feb 10, 2006 04:55 AM|Alex_80|LINK
Hi, I tried it and it works good, I'm able to retrieve all users emails.
but, how can I retrieve all other information?
This example work perfectly to retrieve Email and Name of current object.
How can I take UserName, Office, phone number and all other information stored in Active Directory?
Thanks so much in advance,
Feb 10, 2006 11:10 AM|jrphillips4|LINK
You simply need to know what the field you want is called in Active Directory.
The Office Field is "physicalDeliveryOfficeName"
The Phone Number Field is "telephoneNumber"
You need to be aware that some Property fields may not be available or may not have a value for a particular DirectoryEntry. Here is a link that may help you find out what Property values are available to request
LDAP Property List
Feb 11, 2006 07:54 AM|Alex_80|LINK
thanks so much!!! that's was really what I was searching for!!!!!!!
Feb 14, 2006 11:16 AM|dunnry|LINK