Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recordset only returning 1000 records

I'm doing an ADODB recordset.open() command with an LDAP query to get all the users from my Active Directory.

There are about 2600 users, but I'm only getting back 1000 of them.

I've tried altering the recordset's PageSize and MaxRecords properties with no luck.

Without extraneous stuff, this is what the code looks like (I've made the connection details generic):

ADODB.Connection conn = new ADODB.Connection();
ADODB.Recordset rs = new ADODB.Recordset();
rs.MaxRecords = 10000;
rs.PageSize = 10000;
conn.Open("Active Directory Provider","","",0);
string query = "SELECT cn FROM 'LDAP://OU=User Accounts,OU=TopLevel,DC=domainName,DC=local' where samAccountName = '*'"

rs.Open(query, conn, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic, -1);

It's definitely only returning 1000 records, (I've confirmed), and I can access them just fine.

In case it helps, the reason I'm not using DirectorySearcher is because it's so slow in comparison to this.

like image 255
ChristianLinnell Avatar asked Jun 29 '09 04:06

ChristianLinnell


2 Answers

You have to set the page size on connection, not on the Recordset.

Ref: http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/e483c098-b2c1-4037-b9fb-3c882f3b14c4 http://support.microsoft.com/?kbid=243281

like image 125
J-16 SDiZ Avatar answered Oct 01 '22 19:10

J-16 SDiZ


The 1000 limit is discussed here - essentially, it is fixed at the server, so you're going to need to speak to the owner...

like image 27
Marc Gravell Avatar answered Oct 01 '22 20:10

Marc Gravell