473,322 Members | 1,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Why does it take much time to open a searchresultcollection?

3
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 Searchresultcollection object opens very slowly or produces an exception. maybe someone can help me out?

thanks in advance.

System.DirectoryServices.DirectoryEntry entry = new System.DirectoryServices.DirectoryEntry(ldapcon);
entry.AuthenticationType = AuthenticationTypes.ReadonlyServer;
System.DirectoryServices.DirectorySearcher mysearcher = new System.DirectoryServices.DirectorySearcher(entry);

mysearcher.PropertiesToLoad.Add("sn");
mysearcher.PropertiesToLoad.Add("gn");
mysearcher.PropertiesToLoad.Add("department");
mysearcher.PropertiesToLoad.Add("l");
mysearcher.PropertiesToLoad.Add("c");
mysearcher.PropertiesToLoad.Add("mail");
mysearcher.PropertiesToLoad.Add("tcgid");
mysearcher.SizeLimit = 300;
mysearcher.Filter = filter;
SearchResultCollection results = mysearcher.FindAll();
MessageBox.Show(results.Count.ToString());
foreach (SearchResult rs in results)
{
Apr 25 '12 #1
4 3129
RhysW
70
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)
Apr 25 '12 #2
Senser
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.Connection)
Dim strsql As String
Dim strAdd As String

Dim serverSCD As String

serverSCD = "******"

objConnection.Provider = "ADsDSOObject"
objConnection.Open

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

objRecordset.Open strsql, objConnection, , , adCmdText

End Sub
Apr 25 '12 #3
RhysW
70
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
Apr 25 '12 #4
Senser
3
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 searchresultcollection object, maybe the searchresultcollection object only reffers to the server and has no data in it?
Apr 25 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Rob R. Ainscough | last post by:
I have an interesting problem that is either a bug or just some local issue with my PC (probably the later). If I place my cursor on a word and hit F1 for help, it goes thru a process (see a...
6
by: John Baker | last post by:
Hi: Does "On Open" code execute before or after related data is loaded? I want to test before the form appears on the screen to see if there is any data in the queryresult, and if there is not...
2
by: MS News | last post by:
Hello When I spawn a lightweight process on a new Thread and return immediately to the Client what happens if the lightweight process takes an hour to finish? Under what context is the process...
3
by: Jim Heavey | last post by:
My session do not appear to be timing out. When I save something in ViewState, my expectation is that if no interaction occurs within the specified time, that the session variable would be null. Is...
0
by: Amit | last post by:
Hi, My web.config looks like this: .... <authentication mode="Forms"> <forms name=".ASPXAUTH" protection="All" timeout="2"/> </authentication> .... <sessionState mode="InProc"...
4
by: J M | last post by:
Hi, I have a huge problem in an app I'm writing. I use an OleDbDataset (and OleDbDataTable, and so on, created in the Component Designer) to add rows to a table. Three of the columns have...
17
by: Barret Bonden | last post by:
As an old programmer just now looking at VB.net I have a question: How does one simply open one form from another ? I don't mean how does one create a new instance of that form , but rather how...
2
by: Brett | last post by:
If you paste the URL used in this code into a browser, it will render without errors. Running the code puts it in the Catch with a Time out error but not always. I have ran both (see link below...
2
by: Jim M | last post by:
I rarely deal with recordsets directly with code, since I usually use Access queries, so be patient with this question. I want to open a recordset with various default variables used by my program....
10
by: tyagithehacker | last post by:
C is basically a non-object oriented language, then while doing system programming in UNIX why we have two different versions of OPEN function (system call): int open(const *pathname, int...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.