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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Active Directory script

Status
Not open for further replies.

sthmpsn1

MIS
Sep 26, 2001
456
US
I have the following script that isn't displaying any of the information, but it is displaying "Good Authentication". so I know that it isn't erroring out, but I do know that it doesn't display the users email address. Can someone tell me why?

Try
txtUserID.Text = ""
txtPassword.Text = ""
'Authenticates user name and password with the AD
Dim Entry As New DirectoryEntry("LDAP://somedomain", txtUserID.Text, txtPassword.Text)
Dim Search As New DirectorySearcher(Entry)
Search.PropertiesToLoad.Add("mail")
Dim searchstrg As String
searchstrg = "(&(anr=" + txtUserID.Text + ")(objectCategory=users))"
Search.Filter = searchstrg
Dim results As SearchResultCollection
results = Search.FindAll()
Response.Write("Good Authentication")

Dim prop As SearchResult
For Each prop In results
Response.Write(prop.Properties("mail")(0))
Response.Write("hello")
Next
'clears text box and resets focus
txtUserID.Text = ""
txtPassword.Text = ""

Catch Err As Exception
Response.Write(Err.Message)
txtUserID.Text = "Missed"
txtPassword.Text = ""
End Try
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top