Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 26-02-04, 07:38 PM
Tony Tortora
Guest
 
Posts: n/a

Default SearchResult & SeartchResultCollection failing when Searching a large AD.

I have an Organization Unit that had over 6000 users. I have written a
program that needs to process each user in the OU. First I tried using the
SearchResult and a DirectorySearcher. My first cut the program only
processed 1000 records and quit. I did more reading and I found that the
DirectorySearcher default max is 1000 records. I set the following
parameters:

DirectorySearcher MSearcher = new DirectorySearcher(MLDAP);
MSearcher.Filter = "(objectClass=user)";
MSearcher.CacheResults = false;
MSearcher.SizeLimit = 9000;
MSearcher.PageSize = 500;
MSearcher.PropertiesToLoad.Add("cn");

foreach(System.DirectoryServices.SearchResult result in MSearcher.FindAll())
{
////// code to process the user objects
}


This code always stopped at 1000 records. I change to using a
SearchResultCollection which did select all the records, but in processing
the records I get the following error. I also received this error with the
SearchResult.

"The server is not operational"

Here is my code for using the SearchResultCollection

DirectorySearcher MSearcher = new DirectorySearcher(MLDAP);
MSearcher.Filter = "(objectClass=user)";
MSearcher.CacheResults = false;
MSearcher.SizeLimit = 9000;
MSearcher.PageSize = 500;
MSearcher.PropertiesToLoad.Add("cn");
SearchResultCollection MCollection = MSearcher.FindAll();;

for (MCounter = 0; MCounter <= MCollection.Count - 1; MCounter++)
{
////// code to process the user objects
}

Any idea why this is happening this server stops responding? what is the
best method of processing large amounts of users?

Thank you.


Reply With Quote
  #2 (permalink)  
Old 05-03-04, 07:54 PM
Max L. Vaughn [MSFT]
Guest
 
Posts: n/a

Default RE: SearchResult & SeartchResultCollection failing when Searching a large AD.

Based on the symptoms you have described, this problem may be due to a
known bug. To continue working on this issue, I would recommend you
contact Product Support Services.

Microsoft support home page: http://support.microsoft.com.
To view support options:
http://support.microsoft.com/default...d=sz;en-us;top.
To submit an online request:
http://support.microsoft.com/default...incidentsubmit.
To contact Developer Support by phone: (800) 936-5800

Sincerely,
Max Vaughn [MS]
Microsoft Developer Support


Disclaimer: This posting is provided "AS IS" with no warranties, and
confers no rights. You assume all risk for your use.

Reply With Quote
  #3 (permalink)  
Old 07-03-04, 11:41 PM
Imran Masud
Guest
 
Posts: n/a

Default Re: SearchResult & SeartchResultCollection failing when Searching a large AD.

Hi Tony,
PageSize is used when you want to retreive large volume of date. It is
recommeneded that you use 1000 as PageSize . If you use 500 it will
take more time. In one fetch AD returns 1000 entries which is the
server SizeLimit. When you specify PageSize to be 1000, Directory
Service would retrive all 6000 entries and it would make 6 queries. In
back ground it is making use of Server Side Page Control.
ServerSize SizeLimit is 1000, so even if you specify 9000 it would not
work. It is best to use 1000 as SizeLimit. This Client Size SizeLimit
can be <= SizeLimit set on the AD.


In order to speed up the enumeration use the following for loop

foreach (SearchResult sr in MCollection){
........

}
This should fix your problem. Whenever MCollection.Count is called, it
would enumerate through all the results which is a slow process and
thats why your program halts.
I hope it will help you
CHeers
Imran





"Tony Tortora" <AT@att.com> wrote in message news:<uNDmAfJ$DHA.2800@tk2msftngp13.phx.gbl>...
> I have an Organization Unit that had over 6000 users. I have written a
> program that needs to process each user in the OU. First I tried using the
> SearchResult and a DirectorySearcher. My first cut the program only
> processed 1000 records and quit. I did more reading and I found that the
> DirectorySearcher default max is 1000 records. I set the following
> parameters:
>
> DirectorySearcher MSearcher = new DirectorySearcher(MLDAP);
> MSearcher.Filter = "(objectClass=user)";
> MSearcher.CacheResults = false;
> MSearcher.SizeLimit = 9000;
> MSearcher.PageSize = 500;
> MSearcher.PropertiesToLoad.Add("cn");
>
> foreach(System.DirectoryServices.SearchResult result in MSearcher.FindAll())
> {
> ////// code to process the user objects
> }
>
>
> This code always stopped at 1000 records. I change to using a
> SearchResultCollection which did select all the records, but in processing
> the records I get the following error. I also received this error with the
> SearchResult.
>
> "The server is not operational"
>
> Here is my code for using the SearchResultCollection
>
> DirectorySearcher MSearcher = new DirectorySearcher(MLDAP);
> MSearcher.Filter = "(objectClass=user)";
> MSearcher.CacheResults = false;
> MSearcher.SizeLimit = 9000;
> MSearcher.PageSize = 500;
> MSearcher.PropertiesToLoad.Add("cn");
> SearchResultCollection MCollection = MSearcher.FindAll();;
>
> for (MCounter = 0; MCounter <= MCollection.Count - 1; MCounter++)
> {
> ////// code to process the user objects
> }
>
> Any idea why this is happening this server stops responding? what is the
> best method of processing large amounts of users?
>
> Thank you.

Reply With Quote
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT +1. The time now is 06:21 AM.
Style Developed by Andrew Slane

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
 RSS Feeds - Archive - Top