Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Software > Active directory Interfaces > Slow Directory ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 3 Topic 2264 of 2407
Post > Topic >>

Slow Directory Search

by Bill Schanks <wschanks@[EMAIL PROTECTED] > Apr 22, 2008 at 03:16 PM

I have this code, if I pass in *text* it's very slow (2+ Mins),
however if I pass in text* it lightning fast (< 1 Second). Is there
something wrong with this code? The Directory has 50,000+ Person
Objects, way more Groups.

Is the key to just not allow searches that start with a wildcard?

Function GetMatches(ByVal FilterAttribute As String) As String

        Dim root As New
System.DirectoryServices.DirectoryEntry(m_sPath)
        Dim searcher As New
System.DirectoryServices.DirectorySearcher(root)
        Dim matches As System.Text.StringBuilder = New
System.Text.StringBuilder()
        Dim shtCount As Short

        searcher.Filter = "samaccountname=" & FilterAttribute
        searcher.PropertiesToLoad.Add("samaccountname")

        Dim results As SearchResultCollection
        results = searcher.FindAll
        Dim result As SearchResult

        shtCount = 0

        Try
            For Each result In results
 
matches.Append(result.GetDirectoryEntry.Properties("samaccountname").Value.ToString.ToUpper)
                matches.Append("|")
                shtCount = shtCount + 1
            Next
        Catch ex As System.Exception
            Return Nothing

        Finally
            searcher.Dispose()
            root.Dispose()
        End Try

        Return matches.ToString & CStr(shtCount)
    End Function
 




 3 Posts in Topic:
Slow Directory Search
Bill Schanks <wschanks  2008-04-22 15:16:44 
Re: Slow Directory Search
"Joe Kaplan" &l  2008-04-22 18:33:33 
Re: Slow Directory Search
Bill Schanks <wschanks  2008-04-22 20:02:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Dec 4 22:06:03 CST 2008.