{"record":{"id":"a5b65f0c9bbb9da7","repo":"spring-projects/spring-security","slug":"embedded-ldap-server-is-not-provided-a5b65f","errorCode":null,"errorMessage":"Embedded LDAP server is not provided","messagePattern":"Embedded LDAP server is not provided","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"config/src/main/java/org/springframework/security/config/ldap/EmbeddedLdapServerContextSourceFactoryBean.java","lineNumber":131,"sourceCode":"\t * authenticate to a LDAP server.\n\t */\n\tpublic void setManagerDn(String managerDn) {\n\t\tthis.managerDn = managerDn;\n\t}\n\n\t/**\n\t * The password for the manager DN. This is required if the\n\t * {@link #setManagerDn(String)} is specified.\n\t * @param managerPassword password for the manager DN\n\t */\n\tpublic void setManagerPassword(String managerPassword) {\n\t\tthis.managerPassword = managerPassword;\n\t}\n\n\t@Override\n\tpublic DefaultSpringSecurityContextSource getObject() throws Exception {\n\t\tif (!unboundIdPresent) {\n\t\t\tthrow new IllegalStateException(\"Embedded LDAP server is not provided\");\n\t\t}\n\t\tthis.container = getContainer();\n\t\tthis.port = this.container.getPort();\n\t\tDefaultSpringSecurityContextSource contextSourceFromProviderUrl = new DefaultSpringSecurityContextSource(\n\t\t\t\t\"ldap://127.0.0.1:\" + this.port + \"/\" + this.root);\n\t\tif (this.managerDn != null) {\n\t\t\tcontextSourceFromProviderUrl.setUserDn(this.managerDn);\n\t\t\tif (this.managerPassword == null) {\n\t\t\t\tthrow new IllegalStateException(\"managerPassword is required if managerDn is supplied\");\n\t\t\t}\n\t\t\tcontextSourceFromProviderUrl.setPassword(this.managerPassword);\n\t\t}\n\t\tcontextSourceFromProviderUrl.afterPropertiesSet();\n\t\treturn contextSourceFromProviderUrl;\n\t}\n\n\t@Override\n\tpublic Class<?> getObjectType() {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/spring-projects/spring-security/blob/96852e8860138a482cb13d1479573f24ff6443c6/config/src/main/java/org/springframework/security/config/ldap/EmbeddedLdapServerContextSourceFactoryBean.java#L113-L149","documentation":"EmbeddedLdapServerContextSourceFactoryBean.getObject() builds the embedded LDAP context source, but first checks the unboundIdPresent flag. Since the embedded server relies on UnboundID's SDK, absence of that library means no embedded server can be created and an IllegalStateException is thrown.","triggerScenarios":"Using <ldap-server/> with embedded mode while the UnboundID SDK (com.unboundid:unboundid-ldapsdk) is not on the classpath; getObject() invoked with unboundIdPresent == false.","commonSituations":"Old configs previously backed by ApacheDS (removed in Spring Security 4.x+); dependency management stripping the optional unboundid-ldapsdk; forgetting the embedded LDAP dependency after upgrade.","solutions":["Add com.unboundid:unboundid-ldapsdk to the classpath.","If an external LDAP is intended, use <ldap-server url=\"ldap://host:port/...\"/> instead of embedded mode.","Remove the embedded <ldap-server/> element if LDAP isn't needed."],"exampleFix":"// before\n<ldap-server ldif=\"classpath:test-users.ldif\"/>\n\n// after (pom.xml)\n<dependency>\n  <groupId>com.unboundid</groupId>\n  <artifactId>unboundid-ldapsdk</artifactId>\n</dependency>","handlingStrategy":"validation","validationCode":"boolean ok;\ntry { Class.forName(\"com.unboundid.ldap.sdk.LDAPServer\"); ok = true; }\ncatch (ClassNotFoundException e) { ok = false; }\nif (!ok) throw new IllegalStateException(\"unboundid-ldapsdk required for embedded LDAP\");","typeGuard":null,"tryCatchPattern":"try { ctx.refresh(); }\ncatch (IllegalStateException e) {\n  if (e.getMessage().contains(\"Embedded LDAP server is not provided\")) addUnboundIdDep();\n}","preventionTips":["Include unboundid-ldapsdk when using embedded <ldap-server/>","Remember ApacheDS support was removed in Spring Security 4+","Verify runtime classpath of fat jars"],"tags":["spring-security","ldap","embedded-server","missing-dependency"],"backgroundTag":"missing-dependency","analyzedSha":"96852e8860138a482cb13d1479573f24ff6443c6","analyzedAt":"2026-09-10T23:25:23.477Z","contentChangedAt":"2026-09-10T23:25:23.477Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}