Recordset only returning 1000 records
Asked Answered
I

2

6

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.

Ison answered 29/6, 2009 at 4:5 Comment(0)
B
2

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

Beckiebeckley answered 29/6, 2009 at 4:8 Comment(1)
One of those appears to refer to OLEDB, which I may have to switch to... the other seems to be a registry thing which sadly isn't an option.Ison
C
2

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

Cutpurse answered 29/6, 2009 at 4:11 Comment(2)
I'm pretty sure you can set it from the query - I've done it using VBScript with command.Execute before. It's just I couldn't get that working.Ison
We ran into this exact problem, and we ended up needing to page users based on last name so that individual sets were of less than 1000. It's not an ideal solution, but it worked around this limitation.Sidran

© 2022 - 2024 — McMap. All rights reserved.