【发布时间】:2015-02-12 14:06:06
【问题描述】:
我正在使用 Spring mvc 和针对活动目录的 LDAP 身份验证。我现在拥有的东西可以工作,但我的 contextSource 属性:url、managerDN 和 managerPassword 是硬编码的。我想将这些属性作为资源移动到我的 server.xml 中,并使用数据源来指定这些连接设置。我的想法是 managerDN 可以像用户名一样使用,然后剩下的就可以了。唯一的问题是 contextSource 没有任何方法。 contextSource 是从 contextSourceBuilder 创建的对象。有人对如何做到这一点有任何想法吗?
@Configuration
protected static class AuthenticationConfiguration extends GlobalAuthenticationConfigurerAdapter {
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth
.ldapAuthentication()
.userSearchFilter("sAMAccountName={0}")
.userSearchBase("OU=Accounts")
.groupSearchFilter("member={0}")
.groupSearchBase("OU=Groups")
.contextSource()
.url("ldap://myurl:portNum")
.managerDn("stuff")
.managerPassword("things");
}
}
【问题讨论】:
标签: java spring ldap datasource