spring - 配置2个LDAP服务器

标签 spring spring-security spring-ldap spring-security-ldap

我想知道如何在 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/

相关文章:

spring-boot - Spring Boot 安全性 - 允许用户请求使用过期的 JWT token

java - 仅允许移动设备访问 REST API

java - Spring 4 表单提交

java - 使用 bean 实例化类后立即调用方法(带参数)的最佳方法是什么?

spring - 从 userProfile 检索到的电子邮件为空(Spring Social)

Spring Webflux - 如何在 WebFilter 中调用响应式端点

java - 如何使用 Spring Security 通过 InMemoryAuthentication 登录自定义用户?

spring - Grails Spring 安全 LDAP

java - 为什么 Nginx 以相反的顺序提供客户端 SSL DN?

active-directory - Spring LDAP AD 分页支持不起作用 - LDAP : error code 12 - 00000057: LdapErr: DSID-0C09079A