如何设置spring安全LDAP配置的URL?有很多基于xml的示例,但我找不到一个java配置示例来复制下面的xml行。我假设它是在下面的java代码块中配置的,这些代码块摘自spring指南,用于使用嵌入式ldap,但是我们如何设置外部url呢?
<ldap-server id="ldapServer" url="ldap://example.com:PORT/dc=example,dc=com" />@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.ldif("classpath:test-server.ldif");
}发布于 2014-11-04 08:21:23
您只需使用LdapAuthenticationProviderConfigurer.ContextSourceBuilder的LdapAuthenticationProviderConfigurer.ContextSourceBuilder方法
因此,您可以简单地扩展代码,如下所示:
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.ldif("classpath:test-server.ldif")
.url("ldap://example.com:PORT/dc=example,dc=com");
}https://stackoverflow.com/questions/26720652
复制相似问题