protected Optional<Triple<ConnectionFactory, SearchResponse, LdapAcceptableUsagePolicyProperties>>
        searchLdapForId(final LdapAcceptableUsagePolicyProperties ldap, final String id) throws Exception {

        val filter = LdapUtils.newLdaptiveSearchFilter(ldap.getSearchFilter(),
            LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
            CollectionUtils.wrap(id));
        LOGGER.debug("Constructed LDAP filter [{}]", filter);
        val connectionFactory = new LdapConnectionFactory(connectionFactoryList.get(ldap.getLdapUrl()));
        val response = connectionFactory.executeSearchOperation(ldap.getBaseDn(), filter, ldap.getPageSize());
        if (LdapUtils.containsResultEntry(response)) {
            LOGGER.debug("LDAP query located an entry for [{}] and responded with [{}]", id, response);
            return Optional.of(Triple.of(connectionFactory.getConnectionFactory(), response, ldap));
        }
        LOGGER.debug("LDAP query could not locate an entry for [{}]", id);
        return Optional.empty();
    }
Search ldap for id and return optional.

@param ldap the ldap
@param id   the id
@return the optional
@throws Exception the exception
support/cas-server-support-aup-ldap/src/main/java/org/apereo/cas/aup/LdapAcceptableUsagePolicyRepository.java