{"record":{"id":"bf56c06f22b38313","repo":"apereo/cas","slug":"ldap-url-cannot-be-empty-blank","errorCode":null,"errorMessage":"LDAP url cannot be empty/blank","messagePattern":"LDAP url cannot be empty/blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java","lineNumber":540,"sourceCode":"                            + \"set the pool passivator setting to one of [{}]\",\n                        props.getPoolPassivator(), props.getLdapUrl(), values);\n                }\n            }\n        }\n        LOGGER.debug(\"Initializing LDAP connection pool for [{}] and bindDn [{}]\", props.getLdapUrl(), props.getBindDn());\n        pooledCf.initialize();\n        return pooledCf;\n    }\n\n    /**\n     * New connection config connection config.\n     *\n     * @param properties the ldap properties\n     * @return the connection config\n     */\n    public static ConnectionConfig newLdaptiveConnectionConfig(final AbstractLdapProperties properties) {\n        if (StringUtils.isBlank(properties.getLdapUrl())) {\n            throw new IllegalArgumentException(\"LDAP url cannot be empty/blank\");\n        }\n\n        LOGGER.debug(\"Creating LDAP connection configuration for [{}]\", properties.getLdapUrl());\n        val connectionConfig = new ConnectionConfig();\n\n        val urls = properties.getLdapUrl().contains(\" \")\n            ? properties.getLdapUrl()\n            : String.join(\" \", properties.getLdapUrl().split(\",\"));\n        LOGGER.debug(\"Transformed LDAP urls from [{}] to [{}]\", properties.getLdapUrl(), urls);\n        connectionConfig.setLdapUrl(urls);\n\n        connectionConfig.setUseStartTLS(properties.isUseStartTls());\n        connectionConfig.setConnectTimeout(Beans.newDuration(properties.getConnectTimeout()));\n        connectionConfig.setResponseTimeout(Beans.newDuration(properties.getResponseTimeout()));\n\n        if (StringUtils.isNotBlank(properties.getConnectionStrategy())) {\n            val strategy = AbstractLdapProperties.LdapConnectionStrategy.valueOf(properties.getConnectionStrategy());\n            switch (strategy) {","sourceCodeStart":522,"sourceCodeEnd":558,"githubUrl":"https://github.com/apereo/cas/blob/e7288fc434b4f4505b8452e1a57e8fb3111bb863/support/cas-server-support-ldap-core/src/main/java/org/apereo/cas/util/LdapUtils.java#L522-L558","documentation":"LdapUtils.newLdaptiveConnectionConfig validates that AbstractLdapProperties.getLdapUrl() is non-blank before building an ldaptive ConnectionConfig; an empty URL would otherwise produce a connection factory that cannot connect anywhere. It throws IllegalArgumentException naming the problem.","triggerScenarios":"Building a ConnectionConfig/connection factory from LDAP properties where cas.authn.ldap[x].ldap-url (or the corresponding setLdapUrl) is null, empty, or whitespace — e.g. the property block was added but the URL key was never set.","commonSituations":"Typo in the YAML/properties key (ldapUrl vs ldap-url) so the field stays null; environment-specific config overlay omitted ldap-url; constructing AbstractLdapProperties programmatically without setLdapUrl; placeholder like ${ldap.host} unresolved to empty.","solutions":["Set cas.authn.ldap[x].ldap-url to one or more space-separated LDAP URLs (e.g. ldaps://host:636)","Check for typos or unresolved placeholders in the property name","Validate configuration at startup — run with debug metadata/validation to catch the missing field early","If URLs are supplied per-environment, provide them in the environment's overlay/profile"],"exampleFix":"// before\ncas.authn.ldap[0].ldap-url=\n// after\ncas.authn.ldap[0].ldap-url=ldaps://directory.example.org:636","handlingStrategy":"validation","validationCode":"if (props == null || props.getLdapUrl() == null || props.getLdapUrl().isBlank()) {\n    throw new IllegalStateException(\"cas.authn.ldap[x].ldap-url must be set before building a connection\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    ConnectionConfig cc = LdapUtils.newLdaptiveConnectionConfig(props);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"LDAP url cannot be empty/blank\")) {\n        // fail config load early with a clear message about the missing ldap-url\n    }\n}","preventionTips":["Always set ldap-url first in every ldap[x] block","Check for key typos and unresolved ${placeholders} in YAML/properties","Add a startup config sanity check for required ldap fields","Use spring-configuration-metadata / IDE validation to catch missing required keys"],"tags":["ldap","configuration","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"e7288fc434b4f4505b8452e1a57e8fb3111bb863","analyzedAt":"2026-09-08T15:39:16.015Z","contentChangedAt":"2026-09-08T15:39:16.015Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}