我想知道如何在 spring xml 或 java 配置中配置 2 个 ldap 服务器。我的意思是我不是指使用@Primary。我有 2 个不同的 LDAP 服务器。用户将根据他们所在的域向哪个服务器进行身份验证。例如,如果他们的域是domain1,那么他们需要向ldap1进行身份验证,否则他们将向lda2进行身份验证。 我尝试配置两个 ldap 服务器,但收到一条错误消息,指出允许使用 onlg 1。
最佳答案
我找到了问题的答案。我创建了 2 个配置类,每个类都有自己的 LdapContextSource。然后每个都有 LdapTemplate bean,一个没有标识符,另一个有:
配置1:
@Bean
public LdapTemplate ldapTemplate(@Qualifier("ldapServer1") LdapContextSource contextSource) {
return new LdapTemplate(contextSource);
}
配置2:
@Bean(name = "ldapTemplateDomain2")
public LdapTemplate ldapTemplate(@Qualifier("ldapServer2") LdapContextSource contextSource) {
return new LdapTemplate(contextSource);
}
关于spring - 配置2个LDAP服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55073166/