Search in sources :

Example 1 with SortKey

use of org.forgerock.opendj.ldap.SortKey in project OpenAM by OpenRock.

the class SMSLdapObject method getSearchRequest.

private SearchRequest getSearchRequest(String dn, String filter, SearchScope scope, int numOfEntries, int timeLimit, boolean sortResults, boolean ascendingOrder, String sortAttribute, String... attributes) {
    SearchRequest request = LDAPRequests.newSearchRequest(dn, scope, filter, attributes).setDereferenceAliasesPolicy(DereferenceAliasesPolicy.NEVER).setTimeLimit(timeLimit);
    if (numOfEntries > 0) {
        request.setSizeLimit(numOfEntries);
    }
    if (sortResults) {
        SortKey sortKey = new SortKey(sortAttribute, !ascendingOrder);
        request.addControl(ServerSideSortRequestControl.newControl(true, sortKey));
    }
    return request;
}
Also used : SearchRequest(org.forgerock.opendj.ldap.requests.SearchRequest) SortKey(org.forgerock.opendj.ldap.SortKey)

Aggregations

SortKey (org.forgerock.opendj.ldap.SortKey)1 SearchRequest (org.forgerock.opendj.ldap.requests.SearchRequest)1