4 Replies Latest reply on Mar 3, 2007 11:09 AM by bdaw

    LDAP offset/limit search implementation

    bdaw

      I have little problem with implementation of LDAP searches in portal. In our API we have methods such as:

      Set findUsers(int offset, int limit)
      Set findUsersFilteredByUserName(String filter, int offset, int limit)
      Set findRoleMembers(String roleName, int offset, int limit, String userNameFilter)
      


      For LDAP I use plain JNDI. Problem is that I don't see anything that can be used to implement offset/limit behaviour. In java 1.4 there is a BATCH size. But it doesn't seem to be enough because I don't see a guarantee that same searches will return same set of elements. Am I wrong about it? In typical usage scenario in portal (paginate view of users in UserPortlet) we perform several independent searches.

      I know that there is server side sorting control in for jndi but I'm quite sure it can't be considered as supported by all LDAP servers.

      I also found that in java 1.5 (we need to be 1.4 compliant) there is a PagedResultControl which is quite cool. The funny thing is the statement:
      Note: The Paged Search Control is supported by the Windows Active Directory Server. It's not supported by the Sun Java Directory Server version 5.2

      Which for me it translates into: useless - unless you implement a dedicated solution. But still if we think about separate searches it may not be the exact solution.

      At the moment implementation is dummy - retrieve all, sort and get a sub list - the least efficient solution if you think about LDAP with hundreds of thousand s of users...

      The other possible solution is some kind of caching...

      Any suggestion from LDAP/JNDI gury?