Using System.DirectoryServices to get users names and email addresses

R

RSH

I am using System.DirectoryServices to query our AD in order to get
information about users.

I am having problems understanding how to get at the Username and the Email
address (to begin with)

The code below returns all of the keys (I assume) but I can't figure out how
to extract the values associated with them:

Here is the code I'm using:

Public Sub GetUserProps(SearchChars as string)

Dim sPath As String

Dim fullname As String

Dim objDirEnt As New DirectoryServices.DirectoryEntry("LDAP://server.com",
"user", "pass")

Dim objSearcher As New System.DirectoryServices.DirectorySearcher(objDirEnt)

Dim objSearchRes As System.DirectoryServices.SearchResult

Dim objProps As DictionaryEntry

Dim objvals As String

objSearcher.Filter = ("(anr=" & SearchChars & ")")

For Each objSearchRes In objSearcher.FindAll

For Each objProps In objSearchRes.Properties

Response.Write(objProps.Key & "<br>")

Next

Next

objDirEnt.Close()

End Sub



How do I get at the values for each of the keys?



Thanks you!

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top