PDA

View Full Version : Sorted search result



sverdianto
Jan 3rd, 2007, 12:12 AM
Hi All,

Anybody know how to sort LDAP search result using Spring-LDAP?
If I have this,


+ dc=org
+ dc=eltek
+ ou=users
+ uid=user.a
+ uid=user.c
+ uid=user.b

by using ldapTemplate.search(...), how to get sorted result? (from user.a,user.c,user.b I'll get user.a,user.b,user.c)

Thanks

rasky
Jan 3rd, 2007, 12:00 PM
This could be implemented using a custom DirContextProcessor implementation that you supply to your search. You should subclass AbstractRequestControlDirContextProcessor and implement createRequestControl to create a control of the correct type.

jazzyjava
Jan 14th, 2007, 05:25 PM
Hello Mattias,
What if I wanted both Sorted and Paged results. How can I pass multiple request controls to the LdapTemplate searc(...) method?

Any reason why Sorted request control has no Spring LDAP counterpart, like PagedResultsRequestControl?


Thank you.

ulsa
Jan 15th, 2007, 12:19 AM
If you want to apply more than one DirContextProcessor, you can use AggregateDirContextProcessor which is available in ldap.support.

PagedResultsRequestControl manages the PagedResultsControl, the PagedResultsResponseControl and the associated cookie. None of that is required for a SortControl, and thus no custom DirContextProcessor is needed.

ulsa
Jan 15th, 2007, 01:45 AM
PagedResultsRequestControl manages the PagedResultsControl, the PagedResultsResponseControl and the associated cookie. None of that is required for a SortControl, and thus no custom DirContextProcessor is needed.

Sorry, that's not correct. Too early in the morning for me.

The only way to set a request control is to use a DirContextProcessor, so of course one is needed for SortControl as well. I can't think of any reason why we didn't supply one, other than lack of time.

jazzyjava
Jan 15th, 2007, 06:57 PM
Ulrik,
Thanks for the info. I haven't noticed the AggregateDirContextProcessor class before. Using a custom DirContextProcessor for SortControl is straighforward, and it's already working for me. Any plans to introduce a VLV (Virtual List View) control?

Thank you.

rasky
Jan 16th, 2007, 12:08 AM
Any plans to introduce a VLV (Virtual List View) control?
Actually, that's already in our sandbox. It'll most likely be included in the 1.2 release.