public SearchResponse executeSearchOperation(
        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);
    }
Execute search operation.

@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
support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapConnectionFactory.java