473,508 Members | 4,779 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

retrieving 1000+ users from AD group using C#

4 New Member
I am trying to retrieve 5000 users from AD group, but when I set PageSize= 1000 (or let's say 15000) and SizeLimit=15000, I still get only 1500 users. Any other configuration that I can set (I want to avoid range retrieval as suggested by MS) Please advice. Thanks Below is the code section: Please let me know what am I missing.
Jan 7 '16 #1
5 1957
drastogi
4 New Member
Expand|Select|Wrap|Line Numbers
  1. try
  2. {
  3. searcher.SizeLimit=15000;
  4. searcher.PageSize = 1000; 
  5. return searcher.FindAll();
  6. }
Jan 7 '16 #2
Luk3r
300 Contributor
What is your full code? It appears you likely have a problem with the search string, assuming there really is 5000 users and not only 1500.
Jan 7 '16 #3
drastogi
4 New Member
Expand|Select|Wrap|Line Numbers
  1. private SearchResultCollection ExecuteBestEffortSearch(DirectorySearcher searcher)
  2.     {
  3.       if (searcher == null) { throw new ArgumentNullException("searcher"); }
  4.       if (searcher.SearchRoot == null) { throw new ArgumentException("Directory Searcher does not have a search root.", "searcher"); }
  5.  
  6.       // Construct Search Message
  7.       string message = String.Format("[{0}] ({1}) with filter [{2}] for attributes [{3}]",
  8.         searcher.SearchRoot.Path, searcher.SearchScope, searcher.Filter, FlattenStringCollection(searcher.PropertiesToLoad));
  9.  
  10.       // Execute Search
  11.       try
  12.       {
  13.         if (Logger.DebugLevel >= Logger.MaxDebugLevel)
  14.         {
  15.           Logger.Debug(0, "Executing directory search for " + message, null, DirectoryServiceException.ModuleName, Logger.MaxDebugLevel);
  16.         }
  17.                 searcher.PageSize = 1000; //a positive number to turn off the default page limit in DirectorySearcher
  18.         return searcher.FindAll();
  19.  
  20.        }
  21.       catch (COMException adsiException)
  22.       {
  23.         DirectoryServiceException dsExeception = DirectoryServiceException.Create(
  24.           String.Format("The directory search {0} was unable to execute due to a directory service error.", message), adsiException);
  25.  
  26.         if (dsExeception is DirectoryServerUnavailableException)
  27.         {
  28.           try
  29.           {
  30.             Guid searchRootGuid = searcher.SearchRoot.Guid;
  31.             // Cleanup resources
  32.             searcher.SearchRoot.Dispose();
  33.             // Attempt to Re-Bind
  34.             using (DirectoryEntry searchRootEntry = GetEntryByGuid(searchRootGuid))
  35.             {
  36.                             searcher.PageSize = 1000; //a positive number to turn off the default page limit in DirectorySearcher
  37.               searcher.SearchRoot = searchRootEntry;
  38.               return searcher.FindAll();
  39.             }
  40.           }
  41.           catch (Exception ex)
  42.           {
  43.               Logger.LogError(30019, String.Format("The directory search {0} failed because the search root was unavailable and the server was not able to establish a new bind.", message), ex, DirectoryServiceException.ModuleName, Logger.MinDebugLevel);
  44.           }
  45.         }
  46.         throw dsExeception;
  47.       }
  48.     }
Jan 7 '16 #4
drastogi
4 New Member
And SizeLimit i am defining when i create an object of DirectorySearcher class
Jan 7 '16 #5
Luk3r
300 Contributor
I'm still not seeing in your code where you supply a search filter to only grab user objects.
Jan 7 '16 #6

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

Similar topics

0
1889
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, August 20, 2003 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting...
0
1656
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, September 17, 2003 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting...
0
1525
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, October 15, 2003 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting...
0
1714
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, November 19, 2003 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting...
0
506
by: Betty Harvey | last post by:
Happy 2004! I hope everyone had a great holiday and will have a good new year. The next meeting of the XML Users Group will be held on Wednesday, January 21, 2004 at the American Geophysical...
0
1285
by: info | last post by:
Philadelphia XML Users' Group NEXT MEETING: May 11th, 6:00 to 8:00 pm Update from the Philadelphia XML Users' Group The Users' Group is an open organization that invites participation from...
0
1286
by: Betty Harvey | last post by:
NOTE: This is the last meeting of 2006!! The next meeting of the XML Users Group will be held on Wednesday, November 15, 2006 at the American Geophysical Union (AGU) at 2000 Florida Avenue,...
10
3023
by: Jamunt | last post by:
Hi, I want to create an application in which around 1000 users will be served at one time. All of the users will be sending around 1 mb of data. I will be parsing that data and would insert some...
0
1547
by: Betty Harvey | last post by:
The next meeting of the XML Users Group will be held on Wednesday, March 21, 2006 at the American Geophysical Union (AGU) at 2000 Florida Avenue, N.W., Washington, DC 20009-1277. The meeting starts...
4
3313
by: =?Utf-8?B?V2lsbWVyIEhlcm5hbmRleg==?= | last post by:
An ActiveX component created using ATL under Visual Studio 2003, and it is used in a ASP, runs perfectly under administrator or power users group, however this same object does not run under the...
0
7228
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7058
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5635
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4715
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3206
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1565
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
769
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
426
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.