【问题标题】:Unable to connect the external LDAP server无法连接外部 LDAP 服务器
【发布时间】:2018-04-13 09:36:47
【问题描述】:

我正在使用 spring boot 开发一个 API,它将针对我们公司的 AD 验证用户和密码。我厌倦了嵌入 LDAP 测试服务器的示例示例,它工作得非常好。但是,每当我尝试连接到我们的 LDAP 服务器时,我都会看到以下错误消息。

这就是我正在做的。

protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth
            .ldapAuthentication()
            .userDnPatterns("uid={0},ou=people")
            .groupSearchBase("ou=groups")
            .contextSource()
                .url("ldap://<company AD server>/dc=springframework,dc=org")
                .and()
            .passwordCompare()
                .passwordEncoder(new LdapShaPasswordEncoder())
                .passwordAttribute("userPassword");

错误信息:-

尝试对用户进行身份验证时发生内部错误。 org.springframework.security.authentication.InternalAuthenticationServiceException: LDAP 处理期间发生未分类异常;嵌套的 异常是 javax.naming.NamingException: [LDAP: error code 1 - 000004DC:LdapErr:DSID-0C0906E8,注释:为了执行这个 操作一个成功的绑定必须在连接上完成。,数据 0, v1db1]

我不确定我哪里出错了。我试着用谷歌搜索,但没有运气。我正在使用带有 Spring Security 的 Eclipse。

【问题讨论】:

    标签: java spring spring-security active-directory


    【解决方案1】:

    您需要配置一个允许读取 LDAP 服务器的用户。

    在您的 AuthenticationConfiguration 中,您只是定义了 LDAP 服务器的 URL,但没有允许执行搜索并从那里读取的用户。

    .contextSource()
            .url("ldaps://<ap-ldap-server>")
            .port(639)
            .managerDn("cn=binduser,ou=users,dc=ap,dc=domain,dc=com")
            .managerPassword("some pass")
    

    阅读此答案What login name to use for Spring LDAP authentication 了解如何定义管理器连接

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-24
      • 2018-07-30
      • 2013-05-07
      • 2014-02-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多