private static Pair<String, DirContext> getContext(final String ldapUrl, final String bindDn, final String bindCredential) {
        val urls = StringUtils.commaDelimitedListToSet(ldapUrl);
        for (val url : urls) {
            if (ldapUrl != null && !ldapUrl.isEmpty()) {
                LOGGER.info("Attempting connect to LDAP instance [{}]", url);

                val env = getLdapDirectoryContextSettings(bindDn, bindCredential, url);
                try {
                    return Pair.of(ldapUrl, new InitialDirContext(env));
                } catch (final Exception e) {
                    LOGGER.error("Failed to connect to ldap instance [{}]", ldapUrl);
                }
            }
        }

        return null;
    }
Validate endpoint.

@param url            the url
@param bindDn         the bind dn
@param bindCredential the bind credential
@param baseDn         the base dn
@param searchFilter   the search filter
@param userPassword   the user password
@param userAttributes the user attributes
@return true/false
support/cas-server-support-shell-core/src/main/java/org/apereo/cas/shell/commands/util/ValidateLdapConnectionCommand.java