Ste*_*lon 4 spring ldap spring-security
如何设置spring安全性LDAP配置的URL?有很多基于xml的示例,但我找不到一个java配置示例来复制下面的xml行.我假设它是在以下java代码块中配置的,从弹簧指南中获取使用嵌入式ldap,但我们如何设置外部URL?
<ldap-server id="ldapServer" url="ldap://example.com:PORT/dc=example,dc=com" />
Run Code Online (Sandbox Code Playgroud)
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
auth.ldapAuthentication()
.userDnPatterns("uid={0},ou=people")
.groupSearchBase("ou=groups")
.contextSource()
.ldif("classpath:test-server.ldif");
}
Run Code Online (Sandbox Code Playgroud)
你只需使用的url()方法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");
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6397 次 |
| 最近记录: |