Request that the server sort results before returning them to the client. See RFC 2891. The SortKey class accepts three parameters that control the sorting:
attributeDescription - name of the attribute to sort on
matchingRuleId - matching rule defined by RFC 3698; optional, if not present the attribute’s default matching rule is used
reverseOrder - whether the entries should be presented in reverse sorted order; default is false
Connectionconn=DefaultConnectionFactory.getConnection("ldap://directory.ldaptive.org");try{conn.open();SearchOperationsearch=newSearchOperation(conn);SearchRequestrequest=newSearchRequest("dc=ldaptive,dc=org","(givenName=d*)","cn","sn");SortRequestControlsrc=newSortRequestControl(newSortKey[]{newSortKey("sn","caseExactMatch")},true);// sort by surnamerequest.setControls(src);SearchResultresult=search.execute(request).getResult();for(LdapEntryentry:result.getEntries()){// do something useful with the entry}}finally{conn.close();}
Provider Support
JNDI
JLDAP
Apache LDAP
UnboundID
OpenDJ
✓
✓
✓
✓
✓
✓
Functionality exists in the provider API and has been confirmed
✗
Functionality does not exist in the provider API
✶
Functionality exists in the provider API, but did not work in our test environment
?
Functionality exists in the provider API, but has not been integrated into the ldaptive provider