directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Xu, Yaning" <>
Subject RE: How to implement getIdentities(int start, int limit) more effectively
Date Thu, 02 Jul 2015 08:00:20 GMT
Sorry I forgot to mention my many thanks to Stefan :). Further pointers are much appreciated.


From: Xu, Yaning []
Sent: Thursday, July 02, 2015 3:39 PM
To: Apache Directory Developers List
Subject: How to implement getIdentities(int start, int limit) more effectively

Hi all,

        As we have discussed , IdentityService.getIdentities()
should be removed. However, to implement getIdentities(int start, int limit), which returns
a sorted result, I have to get all identities from the ldap server and then sort them. Is
it possible for the Ldap server to return a sorted result for the client connection?

In [1], I see a test about Page Search on client side testPagedSearchWrongCookie(), and it
uses pagedSearchControl.setSize(3) to set the page size, the problem are:

        *how can I get a search result based on the start index and pageSize, like I may use
getIdentities(int start, int limit) to return a result;

        *how can I get a sorted result from the server, so that I don't have to get all the
entries and then sort them to get the result;


public List<String> getIdentities(int start, int limit) {
    List<String> identities = getIdentities();

    if (limit == -1) {
        return identities;

    return getIdentities().subList(start, start + limit);

private List<String> getIdentities() {
    List<String> identityNames = new ArrayList<>();
    EntryCursor cursor;
    Entry entry;
    try {
        cursor = getConfig().getString("base_dn"),
                "(objectclass=*)", SearchScope.ONELEVEL, KerberosAttribute.KRB5_PRINCIPAL_NAME_AT);
        if (cursor == null) {
            return null;
        while ( {
            entry = cursor.get();
    } catch (LdapException e) {
    } catch (CursorException e) {
    return identityNames;



View raw message