How do I run range queries on LDAP

Ritesh M Nayak picture Ritesh M Nayak · Jan 15, 2010 · Viewed 9.2k times · Source

I am trying to retrieve data about groups on LDAP. As I need to paginate results, I need to run range queries. My setup uses JNDI to connect to LDAP. I am trying to run this query

 (&(objectclass=group)(range=1-500))

What am I doing wrong? I know there are range based queries for LDAP,how do I modify this query for get the same?

Answer

Per Noalt picture Per Noalt · Jan 15, 2010

Well paging is one thing and range is another. You page the results that you get back from the LDAP server when there are more than 1000 entries (at least that's the default in Active Directory).

MSDN has an article on how to do paged searches in .NET; hopefully you can translate that to your environment.

Range is something different. You use range when you have a multi-value-attribute (commonly the member-attribute for a group) that has a large number of values. So you can't have range in the query. You need to specify the range when you access the multi-value-attribute (then instead of just specifying member in the code accessing the property value you specify member;range=1-500 to get the first 500 values from that multivalue attribute).