protected List<DelegatedAuthenticationCandidateProfile> queryLdap(final Pac4jDelegatedAuthenticationLdapProfileSelectionProperties ldap,
                                                                      final UserProfile profile) throws Exception {

        val connectionFactory = LdapUtils.newLdaptiveConnectionFactory(ldap);
        LOGGER.debug("Configured LDAP delegated authentication profile selection via [{}]", ldap.getLdapUrl());
        try (val factory = new LdapConnectionFactory(connectionFactory)) {
            val filter = LdapUtils.newLdaptiveSearchFilter(ldap.getSearchFilter(),
                LdapUtils.LDAP_SEARCH_FILTER_DEFAULT_PARAM_NAME,
                List.of(profile.getId()));
            LOGGER.debug("Fetching user attributes [{}] for [{}] via [{}]", ldap.getAttributes(), profile, filter);
            val result = factory.executeSearchOperation(ldap.getBaseDn(), filter, 0,
                ldap.getAttributes().toArray(ArrayUtils.EMPTY_STRING_ARRAY));
            LOGGER.debug("Found entries: [{}]", result.getEntries().size());
            return result
                .getEntries()
                .stream()
                .map(entry -> {
                    LOGGER.trace("Found entry [{}]", entry);
                    var attributes = new HashMap<>(profile.getAttributes());
                    for (val attr : entry.getAttributes()) {
                        attributes.put(attr.getName(), attr.getStringValues());
                    }
                    val name = Optional.ofNullable(entry.getAttribute(ldap.getProfileIdAttribute()))
                        .map(LdapAttribute::getStringValue)
                        .orElseGet(profile::getId);
                    LOGGER.debug("Adding attributes [{}] to the selected profile: [{}]", attributes, name);
                    return DelegatedAuthenticationCandidateProfile.builder()
                        .attributes(attributes)
                        .id(name)
                        .key(UUID.randomUUID().toString())
                        .linkedId(profile.getId())
                        .build();
                })
                .collect(Collectors.toList());
        }
    }
This is {@link LdapDelegatedClientAuthenticationCredentialResolver}.

@author Misagh Moayyed
@since 7.0.0
support/cas-server-support-pac4j-core/src/main/java/org/apereo/cas/authentication/principal/ldap/LdapDelegatedClientAuthenticationCredentialResolver.java