Hi,
I hope this is an OK question to post to the list.

I'm running the code below against OpenLDAP 2.4.40. I based the code on an
integration test for SortRequestControl. However, this code does not return
the entries in the order I expect (alphabetical by sn). Can you tell me
what I am missing?
Thanks for any help!

    SearchRequest req = new SearchRequestImpl();
    req.setScope(SearchScope.ONELEVEL);
    req.addAttributes("*");
    req.setTimeLimit(0);
    req.setBase(searchDn);
    req.setFilter("(objectclass=posixAccount)");

    SortRequest sortRequest = new SortRequestControlImpl();
    sortRequest.addSortKey(new SortKey("sn"));
    req.addControl(sortRequest);

   try (SearchCursor cursor = connection.search(req)) {
         while (cursor.next()) {
                SearchResultEntry se = (SearchResultEntry) cursor.get();
                Entry entry = se.getEntry();
                System.out.println("sn: " + entry.get("sn").getString());

        }
    }

Reply via email to