How do I run range queries on LDAP

2019-07-30 04:15发布

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?

3条回答
该账号已被封号
2楼-- · 2019-07-30 04:32

Instead of Simple Paging control you may consider using Virtual List View control if your AD is version 2003 or above. Virtual List View provided advanced result sorting options and gives you more power in controlling the subset of the search result set.

查看更多
Melony?
3楼-- · 2019-07-30 04:35

This is how you need to query to get results

int start = 0;
int step = 1500;
int finish = 1499;
boolean finished = false;
String range;

String returnedAtts[] = {"member;Range=" + range};
searchCtls.setReturningAttributes(returnedAtts);
NamingEnumeration answer = readableDirContext.search(searchDN, searchFilter, searchCtls);
查看更多
爷、活的狠高调
4楼-- · 2019-07-30 04:48

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).

查看更多
登录 后发表回答