Larry Brister
asked on
Directory Searcher Filter
I have a class that's getting the information I want but running too long
I THINK I need a filter on my Searcher.FindAll()
I want to look for a particular "user" based on thier login name
The FUnction is called with the following function and the "incomingUsername" is set with
HttpContext.Current.User.I dentity.Na me.ToStrin g()
Public Function getUserInfo(ByVal incomingUserName As String) As String
getUserData = LoadADSIDetails("", incomingUserName)
Return getUserData
End Function
Following code starts a loop...
I want to apply a filter somehow
I THINK I need a filter on my Searcher.FindAll()
I want to look for a particular "user" based on thier login name
The FUnction is called with the following function and the "incomingUsername" is set with
HttpContext.Current.User.I
Public Function getUserInfo(ByVal incomingUserName As String) As String
getUserData = LoadADSIDetails("", incomingUserName)
Return getUserData
End Function
Following code starts a loop...
I want to apply a filter somehow
blah...blah...blah...
Public Function LoadADSIDetails(ByVal Query As String, ByVal incomingUserName As String) As String
Dim counter As Int16 = 0
Dim searcher As New DirectorySearcher("")
Dim DataToWrite As String = Nothing
Try
If Query.Trim.Length = 0 Then
searcher.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))(objectCategory=user))"
Else
searcher.Filter = "(&(!(userAccountControl:1.2.840.113556.1.4.803:=2))(objectCategory=user)(" + Query + "))"
End If
searcher.SearchScope = SearchScope.Subtree
Dim FirstName, SurName, Email, UserName, GroupName As String
For Each result As SearchResult In searcher.FindAll()
blah...blah...blah...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
what is Query?
ASKER
Great!
Thanks
Thanks