Why does it take much time to open a searchresultcollection?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Senser
    New Member
    • Apr 2012
    • 3

    Why does it take much time to open a searchresultcollection?

    Hello I am trying to write a litte program which let users search für other users with an LDAP connection.
    It works fine with some search operations but it takes a very long time to "open" the searchresult object, it produces an COMException with some querys, others work fine. i have no idea why this takes this much time. if i debug step by step the .FindAll() works fine but the message box takes about 3 seconds or produces an exception. the result is limited to 300 results by the server.

    my problem is that the Searchresultcol lection object opens very slowly or produces an exception. maybe someone can help me out?

    thanks in advance.

    System.Director yServices.Direc toryEntry entry = new System.Director yServices.Direc toryEntry(ldapc on);
    entry.Authentic ationType = AuthenticationT ypes.ReadonlySe rver;
    System.Director yServices.Direc torySearcher mysearcher = new System.Director yServices.Direc torySearcher(en try);

    mysearcher.Prop ertiesToLoad.Ad d("sn");
    mysearcher.Prop ertiesToLoad.Ad d("gn");
    mysearcher.Prop ertiesToLoad.Ad d("department") ;
    mysearcher.Prop ertiesToLoad.Ad d("l");
    mysearcher.Prop ertiesToLoad.Ad d("c");
    mysearcher.Prop ertiesToLoad.Ad d("mail");
    mysearcher.Prop ertiesToLoad.Ad d("tcgid");
    mysearcher.Size Limit = 300;
    mysearcher.Filt er = filter;
    SearchResultCol lection results = mysearcher.Find All();
    MessageBox.Show (results.Count. ToString());
    foreach (SearchResult rs in results)
    {
  • RhysW
    New Member
    • Mar 2012
    • 70

    #2
    This error is linked sometimes to it not having access/permission to view/access the folder you want it to search. Are you sure this isnt the problem? i can see you are making your code access the directories so there is a chance it can access most of them but maybe not some, which would explain why some queries work and others dont (the ones that dont probably try to access something its not allowed to do)

    Comment

    • Senser
      New Member
      • Apr 2012
      • 3

      #3
      I am not quit sure, but if i reduce the size limit to about 200~250 the code works.(takes some time but complete the foreach) if i change the value over 260 it crashes every time.

      I've tested your point(simply split my error query in 5 parts) and every single part with about 50 results works. Do you have any other idea what could be the problem? I also noticed that if i debug step by step and i click at the "+" at results right after i passed Find.All() it also crashes.

      Thanks


      EDIT:
      I also got the VB Code which works fine but i don't know how to change it correctly to c#

      Public Sub sucheSCD(sel As String, where As String, ByRef objRecordset As ADODB.Recordset , ByRef objConnection As ADODB.Connectio n)
      Dim strsql As String
      Dim strAdd As String

      Dim serverSCD As String

      serverSCD = "******"

      objConnection.P rovider = "ADsDSOObje ct"
      objConnection.O pen

      strsql = "SELECT " & sel & " " & _
      "FROM '" & serverSCD & "' " & _
      "WHERE " & where & " "

      objRecordset.Op en strsql, objConnection, , , adCmdText

      End Sub

      Comment

      • RhysW
        New Member
        • Mar 2012
        • 70

        #4
        hmm, is this the ONLY code related to searching and posting results? or are there more?, also which line is the COM exception coming from? (it tells you normally when debugging where the error comes from) this may help narrow it down

        Comment

        • Senser
          New Member
          • Apr 2012
          • 3

          #5
          Yes this is the only code, some lines above i define the filter which i then give to the mysearcher. The COM Exception comes from the Message Box, if i comment it out it comes from the "foreach" line. The COM exception exactly says:"Das Zeitlimit für diese Anforderung wurde überschritten." which means The timelimit for this operation exceeded.
          I've also captured this screenshot. http://imgur.com/kVSWp
          this occurs if i click the plus while debugging after .findall(). there seems to be something wrong with the searchresultcol lection object, maybe the searchresultcol lection object only reffers to the server and has no data in it?

          Comment

          Working...