开发者

How do I run range queries on LDAP

开发者 https://www.devze.com 2022-12-16 06:32 出处:网络
I am trying to retrieve data about groups on LDAP. As I need to paginate results, I need to run range queries. My set开发者_JAVA技巧up uses JNDI to connect to LDAP. I am trying to run this query

I am trying to retrieve data about groups on LDAP. As I need to paginate results, I need to run range queries. My set开发者_JAVA技巧up 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?


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


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.


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);
0

精彩评论

暂无评论...
验证码 换一张
取 消