Hello. When doing an OPENQUERY against Active Directory,
I hit the 1000 row limit. THat's all this query below
will return. We can get this to work, by writing in
VBSCRIPT and then reading multiple sets of 1000. Would
anyone know a way to use the SQL format below to get
beyond the 1000 row limit? I know there's a RANGE
parameter in ADO, but not sure IF or HOW to code for that
in an OPENQUERY... THanks, Bruce
SELECT givenName, sn, cn, mail, samAccountName
FROM OPENQUERY( ADSI, '<LDAP://domain_name>;
(&(objectCategory=person)(objectClass=User));
givenName,sn,cn,mail,samAccountName;subtree')Bruce,
You can do something like this:
1. Order the data returning from ADSI.
2. Find the max value returned.
3. Query again, starting after the last max value.
4. Loop until done.
I don't know of a way to get the entire result set back with TSQL.
Russell Fields
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:090301c3bdaa$70026140$a501280a@.phx.gbl...
> Hello. When doing an OPENQUERY against Active Directory,
> I hit the 1000 row limit. THat's all this query below
> will return. We can get this to work, by writing in
> VBSCRIPT and then reading multiple sets of 1000. Would
> anyone know a way to use the SQL format below to get
> beyond the 1000 row limit? I know there's a RANGE
> parameter in ADO, but not sure IF or HOW to code for that
> in an OPENQUERY... THanks, Bruce
>
> SELECT givenName, sn, cn, mail, samAccountName
> FROM OPENQUERY( ADSI, '<LDAP://domain_name>;
> (&(objectCategory=person)(objectClass=User));
> givenName,sn,cn,mail,samAccountName;subtree')
>
>|||Thanks Russell. Yes, it doesn't appear that you can get
ALL rows returned in one SQL statement, and I'm fine with
the loop method via SQL. But I can't seem to get that
working either. Seems like howeer I feliter in my query,
it's filtering within the 1000 max rows... Any way you
know to get more then the 1000 rows? Is there a range
parameter in LDAP, that will do the NEXT 1000 rows,
something like that' THanks, Bruce
>--Original Message--
>Bruce,
>You can do something like this:
>1. Order the data returning from ADSI.
>2. Find the max value returned.
>3. Query again, starting after the last max value.
>4. Loop until done.
>I don't know of a way to get the entire result set back
with TSQL.
>Russell Fields
>"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
>news:090301c3bdaa$70026140$a501280a@.phx.gbl...
>> Hello. When doing an OPENQUERY against Active
Directory,
>> I hit the 1000 row limit. THat's all this query below
>> will return. We can get this to work, by writing in
>> VBSCRIPT and then reading multiple sets of 1000. Would
>> anyone know a way to use the SQL format below to get
>> beyond the 1000 row limit? I know there's a RANGE
>> parameter in ADO, but not sure IF or HOW to code for
that
>> in an OPENQUERY... THanks, Bruce
>>
>> SELECT givenName, sn, cn, mail, samAccountName
>> FROM OPENQUERY( ADSI, '<LDAP://domain_name>;
>> (&(objectCategory=person)(objectClass=User));
>> givenName,sn,cn,mail,samAccountName;subtree')
>>
>
>.
>|||Bruce,
I don't see my earlier reply, so I will try again.
Actually you need to plan your queries to bring back less that 1000 rows.
(NOT as clean as getting 1000, then the next 1000, etc.) For example,
within the query you might have:
x = 'smtp:Pager1*' -- brings back everything that matches this pattern
(in SQL terms "Like 'Pager1%'")
x = 'smtp:Pager2*' etc.
Russell Fields
"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
news:078801c3be5b$44f05b90$a001280a@.phx.gbl...
> Thanks Russell. Yes, it doesn't appear that you can get
> ALL rows returned in one SQL statement, and I'm fine with
> the loop method via SQL. But I can't seem to get that
> working either. Seems like howeer I feliter in my query,
> it's filtering within the 1000 max rows... Any way you
> know to get more then the 1000 rows? Is there a range
> parameter in LDAP, that will do the NEXT 1000 rows,
> something like that' THanks, Bruce
>
> >--Original Message--
> >Bruce,
> >
> >You can do something like this:
> >1. Order the data returning from ADSI.
> >2. Find the max value returned.
> >3. Query again, starting after the last max value.
> >4. Loop until done.
> >
> >I don't know of a way to get the entire result set back
> with TSQL.
> >
> >Russell Fields
> >
> >"Bruce de Freitas" <bruce@.defreitas.com> wrote in message
> >news:090301c3bdaa$70026140$a501280a@.phx.gbl...
> >> Hello. When doing an OPENQUERY against Active
> Directory,
> >> I hit the 1000 row limit. THat's all this query below
> >> will return. We can get this to work, by writing in
> >> VBSCRIPT and then reading multiple sets of 1000. Would
> >> anyone know a way to use the SQL format below to get
> >> beyond the 1000 row limit? I know there's a RANGE
> >> parameter in ADO, but not sure IF or HOW to code for
> that
> >> in an OPENQUERY... THanks, Bruce
> >>
> >>
> >> SELECT givenName, sn, cn, mail, samAccountName
> >> FROM OPENQUERY( ADSI, '<LDAP://domain_name>;
> >> (&(objectCategory=person)(objectClass=User));
> >> givenName,sn,cn,mail,samAccountName;subtree')
> >>
> >>
> >>
> >
> >
> >.
> >
Showing posts with label openquery. Show all posts
Showing posts with label openquery. Show all posts
Monday, March 19, 2012
Sunday, March 11, 2012
Active Directory 1000 rows limitation
we are using
select distinguishedname, employeeid, sn, middlename, givenname, displayname, samaccountname, mail, cn, telephonenumber
from OpenQuery( ADSI, 'SELECT telephonenumber, distinguishedname, employeeid, sn, middlename, givenname, displayname, samaccountname, mail, cn, telephonenumber
FROM ''LDAP://DC=domain,DC=xxx,DC=xxx''
WHERE objectCategory = ''Person'' AND objectClass= ''user''
But it only returns 1000 rows which i read all around that is the default.
How do you set this to be higher.
Thanks
Try adding the connection attribute "Page Size" to your connection string and specify higher value. By default, the ADSI search API restricts the first result set size to 1000 rows and the rest of the rows have to be paged one by one. There are probably other connection string attributes that needs to be specified for the search result to be expanded. I do not know the exact details so you will have to check the ADSI OLEDB provider documentation.
Labels:
active,
database,
directory,
displayname,
distinguishedname,
employeeid,
givenname,
limitation,
mail,
microsoft,
middlename,
mysql,
openquery,
oracle,
rows,
samaccountname,
select,
server,
sql,
telephonenumber
Subscribe to:
Posts (Atom)