Code to Handle results greater than 1000


I work for an organization with over 18K users and the Linq To AD code only returned 1000 records. I have adjusted the code to handle these two issues:
1) 1000 limit on returned records.
2) Possible memory leak due to not properly disposing of (DirectorySearcher.FindAll Method) as reported on the FindAll help page, remarks section, on MSDN.
In fixing the code I have do the following using on the client side to accomodate for issue #2 :
using ( var usersDS = new DirectorySource<User>( ROOT, SearchScope.Subtree ) )
users = from usr in usersDS
        select usr;
users = users.OrderBy( user => user.Name ).ToList(); // Sort by name after the fact.
I have uploaded my DirectorySource.cs which addresses those two issues.

file attachments


afraan wrote Jan 20, 2009 at 2:22 AM

Is this mod to the latest version?
Just a quick browse and one constructor seems to be missing from DirectorySource class (compared to latest version)

asin wrote Apr 23 at 1:44 PM

thank you OmegaMan
Your changes works perfectly

One question.
I don´t see the differences with the original file.
Why the original file returns only 1000 records?

What changes have you made ​​in your DirectorySource to solve the problem?

It's just for my knowledge