P
Patrick.O.Ige
The code below works fine but if i use
Response.Write("First Name=" + result.Properties("givenname")(0) + "<br>Last
Name=" + result.Properties("sn")(0) + "")
To display the results it doesn't work unless i do
"result.GetDirectoryEntry.Properties("sn").Value"
to get a value and using GetDirectoryEntry makes the query very slow.
But if i filter by using :-
Mysearcher.Filter = "(&(anr=username)(objectCategory=person))"
I can retrieve result by doing :
Response.Write("First Name=" + result.Properties("givenname")(0) + "<br>Last
Name=" + result.Properties("sn")(0) + "")
What am i doing wrong?
Any advice?
Dim Mysearcher As New DirectorySearcher(rootEntry)
'Mysearcher.Filter = "(&(anr=username)(objectCategory=person))"
Mysearcher.Filter = "(&(objectClass=user)(objectCategory=user))"
Mysearcher.PropertiesToLoad.Add("samaccountname")
Mysearcher.PropertiesToLoad.Add("givenname")
Mysearcher.PropertiesToLoad.Add("sn")
Mysearcher.PropertiesToLoad.Add("mail")
Dim Myresults As SearchResultCollection
Myresults = Mysearcher.FindAll()
Dim result As SearchResult
For Each result In Myresults
Response.Write("" &
result.GetDirectoryEntry().Properties("samaccountname").Value & "<br>")
'Response.Write("First Name=" + result.Properties("givenname")(0) +
"<br>Last Name=" + result.Properties("sn")(0) + "")
'Response.Write("" & result.Properties("sn")(0) & "")
'Response.Write("<br>Email=" + result.Properties("mail")(0) + "<br>")
Response.Write("" + result.GetDirectoryEntry.Properties("sn").Value +
"<br>")
Next
Response.Write("First Name=" + result.Properties("givenname")(0) + "<br>Last
Name=" + result.Properties("sn")(0) + "")
To display the results it doesn't work unless i do
"result.GetDirectoryEntry.Properties("sn").Value"
to get a value and using GetDirectoryEntry makes the query very slow.
But if i filter by using :-
Mysearcher.Filter = "(&(anr=username)(objectCategory=person))"
I can retrieve result by doing :
Response.Write("First Name=" + result.Properties("givenname")(0) + "<br>Last
Name=" + result.Properties("sn")(0) + "")
What am i doing wrong?
Any advice?
Dim Mysearcher As New DirectorySearcher(rootEntry)
'Mysearcher.Filter = "(&(anr=username)(objectCategory=person))"
Mysearcher.Filter = "(&(objectClass=user)(objectCategory=user))"
Mysearcher.PropertiesToLoad.Add("samaccountname")
Mysearcher.PropertiesToLoad.Add("givenname")
Mysearcher.PropertiesToLoad.Add("sn")
Mysearcher.PropertiesToLoad.Add("mail")
Dim Myresults As SearchResultCollection
Myresults = Mysearcher.FindAll()
Dim result As SearchResult
For Each result In Myresults
Response.Write("" &
result.GetDirectoryEntry().Properties("samaccountname").Value & "<br>")
'Response.Write("First Name=" + result.Properties("givenname")(0) +
"<br>Last Name=" + result.Properties("sn")(0) + "")
'Response.Write("" & result.Properties("sn")(0) & "")
'Response.Write("<br>Email=" + result.Properties("mail")(0) + "<br>")
Response.Write("" + result.GetDirectoryEntry.Properties("sn").Value +
"<br>")
Next