【发布时间】:2022-10-21 02:45:49
【问题描述】:
测试 ma LDAP 服务。我像这样设置嵌入式 LDAP 配置:
spring:
ldap:
base: OU=Internals,DC=int,DC=springboot,DC=dev
username: uid=admin
password: secret
urls: ldap://localhost:8389/
embedded:
base-dn: DC=springboot,DC=dev
credential:
username: uid=admin
password: secret
ldif: classpath:export2-ldap.ldif
port: 8389
validation:
enabled: false
我研究了EmbeddedLdapAutoConfiguration 和LdapAutoConfiguration 代码,我注意到EmbeddedLdapAutoConfiguration 在LdapAutoConfiguration 类之前创建了一个没有基础的bean LdapContextSource。
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(ContextSource.class)
static class EmbeddedLdapContextConfiguration {
@Bean
@DependsOn("directoryServer")
@ConditionalOnMissingBean
LdapContextSource ldapContextSource(Environment environment, LdapProperties properties,
EmbeddedLdapProperties embeddedProperties) {
LdapContextSource source = new LdapContextSource();
if (embeddedProperties.getCredential().isAvailable()) {
source.setUserDn(embeddedProperties.getCredential().getUsername());
source.setPassword(embeddedProperties.getCredential().getPassword());
}
source.setUrls(properties.determineUrls(environment));
return source;
}
}
是否正常,不能同时使用 spring.ldap.base 和 spring.ldap.embedded.* ?或者我的项目中可能没有正确设置某些东西。
【问题讨论】:
标签: java spring spring-boot ldap spring-ldap