Search in sources :

Example 1 with FollowSearchReferralHandler

use of org.ldaptive.referral.FollowSearchReferralHandler in project cas by apereo.

the class LdapUtils method executeSearchOperation.

/**
 * Execute search operation.
 *
 * @param connectionFactory the connection factory
 * @param baseDn            the base dn
 * @param filter            the filter
 * @param pageSize          the page size
 * @param binaryAttributes  the binary attributes
 * @param returnAttributes  the return attributes
 * @return the response
 * @throws LdapException the ldap exception
 */
public static SearchResponse executeSearchOperation(final ConnectionFactory connectionFactory, final String baseDn, final FilterTemplate filter, final int pageSize, final String[] binaryAttributes, final String[] returnAttributes) throws LdapException {
    val request = LdapUtils.newLdaptiveSearchRequest(baseDn, filter, binaryAttributes, returnAttributes);
    if (pageSize <= 0) {
        val searchOperation = new SearchOperation(connectionFactory);
        searchOperation.setSearchResultHandlers(new FollowSearchReferralHandler());
        return searchOperation.execute(request);
    }
    val client = new PagedResultsClient(connectionFactory, pageSize);
    return client.executeToCompletion(request);
}
Also used : lombok.val(lombok.val) PagedResultsClient(org.ldaptive.control.util.PagedResultsClient) SearchOperation(org.ldaptive.SearchOperation) FollowSearchReferralHandler(org.ldaptive.referral.FollowSearchReferralHandler)

Aggregations

lombok.val (lombok.val)1 SearchOperation (org.ldaptive.SearchOperation)1 PagedResultsClient (org.ldaptive.control.util.PagedResultsClient)1 FollowSearchReferralHandler (org.ldaptive.referral.FollowSearchReferralHandler)1