protected boolean doesSurrogateAccountExistInLdap(final String surrogate,
                                                      final LdapConnectionFactory connectionFactory,
                                                      final SurrogateLdapAuthenticationProperties ldap) throws Throwable {
        if (StringUtils.isBlank(ldap.getSurrogateValidationFilter())) {
            return true;
        }
        val validationFilter = LdapUtils.newLdaptiveSearchFilter(ldap.getSurrogateValidationFilter(),
            "surrogate", List.of(surrogate));
        LOGGER.debug("Using surrogate validation filter [{}] to verify surrogate account [{}]", validationFilter, surrogate);
        val response = connectionFactory.executeSearchOperation(ldap.getBaseDn(), validationFilter, ldap.getPageSize());
        LOGGER.debug("LDAP validation response: [{}]", response);
        return LdapUtils.containsResultEntry(response);
    }
This is {@link SurrogateLdapAuthenticationService}.

@author Misagh Moayyed
@since 5.1.0
support/cas-server-support-surrogate-authentication-ldap/src/main/java/org/apereo/cas/authentication/surrogate/SurrogateLdapAuthenticationService.java