Question : Help with SQL Server ADSI LDAP query

I am attempting to write a query from SQL Server to query our AD.  I am able to connect fine and I get results but it is limited to 1000 rows.  However, it is returning every object in the domain not just users, which is what I specified in my LDAP query.  Either of 2 solutions would be fine.  How can I get more than 1000 rows from an LDAP query or why is my query returning every object instead of just "User"?  I am using SQL Server 2008 and the AD is installed on a DC running Win2k3.
Code Snippet:
1:
SELECT *,GetDate() FROM OpenQuery(ADSI, 'SELECT distinguishedName, mail, title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn FROM ''LDAP://DC=N/A,DC=N/A,DC=N/A'' where objectClass = ''User''')

Answer : Help with SQL Server ADSI LDAP query

To retreive more then 1000 records you need to increase the buffer size.below artical is for win2k but just check the same setting for win2k3

http://support.microsoft.com/kb/243281/en-us

Can you try this to just retrieve user objects

SELECT *,GetDate() FROM OpenQuery(ADSI, 'SELECT distinguishedName, mail, title, displayName, sAMAccountName, givenName, telephoneNumber, facsimileTelephoneNumber, sn FROM ''LDAP://DC=N/A,DC=N/A,DC=N/A'' where objectClass = ''User'')  

Random Solutions  
 
programming4us programming4us