1
Vote

Trying to get all users in a group is limited to 1500 records

description

When I do a query to get all users in a group like the one below (where "MyGroups" is AD Groups):
            var res = from i in ctx.MyGroups
                      where i.Name == GroupName
                      select i.Members;
The results are limited to 1500 records. I believe there is some way to get around this limitation of the Directory Searcher using the "range":
 
DirectorySearcher groupMember = new DirectorySearcher
(group,"(objectClass=*)",new string[]{"member;Range=0-500"},SearchScope.Base);
(http://bcheul.tistory.com/archive/200811)
 
It would be nice if your LINQ provider knew when it had hit 1500, then did another query for the next 1500 and so on until it had all users, then merged the results into the one list. At the moment I am going to have to try and do this manually.

comments

adeelsansari wrote Oct 9, 2010 at 5:18 AM

I am also having this issue, has anyone able to get around it?

jay_burling wrote Apr 30, 2012 at 2:41 PM

This has to do with the paging of results returned from AD. If you wrap the FindAll() call in DirectoryQuery<T>.GetResults() with a using and set a page size, it will continue until it retrieves all the results. Something like:

using ( var s = new DirectorySearcher( root, q, properties.ToArray(), _source.Scope ) )
{
       s.PageSize = 1000;
       ...
       foreach (SearchResult sr in s.FindAll())
       ...
}

wrote Feb 14, 2013 at 6:56 PM