首页
学习
活动
专区
圈层
工具
发布

for LDAP
EN

Stack Overflow用户
提问于 2014-11-03 18:31:47
回答 1查看 6.7K关注 0票数 4

如何设置spring安全LDAP配置的URL?有很多基于xml的示例,但我找不到一个java配置示例来复制下面的xml行。我假设它是在下面的java代码块中配置的,这些代码块摘自spring指南,用于使用嵌入式ldap,但是我们如何设置外部url呢?

代码语言:javascript
复制
<ldap-server id="ldapServer" url="ldap://example.com:PORT/dc=example,dc=com" />
代码语言:javascript
复制
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
    auth.ldapAuthentication()
            .userDnPatterns("uid={0},ou=people")
            .groupSearchBase("ou=groups")
            .contextSource()
                .ldif("classpath:test-server.ldif");
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-11-04 08:21:23

您只需使用LdapAuthenticationProviderConfigurer.ContextSourceBuilderLdapAuthenticationProviderConfigurer.ContextSourceBuilder方法

因此,您可以简单地扩展代码,如下所示:

代码语言:javascript
复制
@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");
}
票数 9
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26720652

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档