Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do retrieve the users email from active directory

Status
Not open for further replies.

tango1948

Programmer
Dec 23, 2006
111
IL
Hi

I have the following code:


Code:
Dim dsDirectoryEntry As DirectoryEntry
Dim dsSearch as DirectorySearcher
Dim result As SearchResultCollection
Dim result1 As SearchResult
Dim aName As String = "David"
dsDirectoryEntry = New DirectoryEntry(LDAPconnstring)
dsSearch = New DirectorySearcher(dsDirectoryEntry)
With dsSearch
   .Filter = "(samAccountName=" & aName &")"
   .PropertyNamesOnly = True
   .PropertiesToLoad.Add("mail")
    result = .FindAll()
End With
If result.count = 1 Then
   Response.Write("the email for " & aName & " is "  & [COLOR=red]email address [/color]
End If
Please could someone complete the above Response.Write with the property that contains the users email




Thanks very much

David
 
Code:
//C# looks like this
result.Properties["mail"[0];

//vb I think look like this
result.Properties("mail")(0)

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top