ldap身份验证开始之前如何配置LdapTemplate?

时间:2019-07-18 06:52:49

标签: spring-boot spring-security ldap-query spring-security-ldap unboundid-ldap-sdk

我正在尝试构建一个基于ldap“ OU”的springboot应用程序,我可以在其中获取 在运行时通过标头使用OU名称,但是spring security不允许我这样做吗?

默认LdapTemplate Bean是通过spring.boot通过application.properties配置创建的。

spring.ldap.base=ou=changeable,dc=abc,dc=com
spring.ldap.username=uid=admin,dc=abc,dc=com
spring.ldap.userDnPatterns=uid={0},ou=users
spring.ldap.groupSearchBase=ou=groups

我想要的是通过覆盖现有的LdapTemplate通过API请求更改Ldap.base的值

@Primary
public LdapContextSource contextSourceTarget(LdapProperties ldapProperties) {
    LdapContextSource contextSource = new LdapContextSource();
    contextSource.setUrl(env.getProperty("spring.ldap.url"));
    contextSource.setBase("ou=newValue,dc=dbr,dc=com");
    contextSource.setUserDn(env.getProperty("spring.ldap.userDnPatterns"));
    return contextSource ;
}

@Bean(name = "updateContext")
@Primary
public LdapTemplate ldapTemplate(LdapContextSource contextSource) {
    return new LdapTemplate(contextSource);
}

我的userDn模式应该从ou = changeable更改为ou = newValue我该怎么做?

我可以在Spring安全身份验证之前动态更改LdapTemplate配置

https://github.com/spring-projects/spring-boot/issues/17564

0 个答案:

没有答案
相关问题