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
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