LDAP无效登录凭据

时间:2016-03-15 11:21:40

标签: spring ldap openldap spring-ldap

我在我的ubuntu 12.04系统上安装了sldap。https://help.ubuntu.com/community/OpenLDAPServer 我可以从terminal.e.g向lsdap添加/搜索记录。我可以添加ldif文件。

ldapadd -x -D cn=admin,dc=test,dc=com -W -f ldap-add.ldif

它问我密码。我输入了pass000并添加了新的条目。工作正常.i可以从终端添加搜索记录。现在我从我的spring应用程序中尝试了它。我将依赖ldap-core添加到我的pom .i设置bean等等。除了它让我在有效凭证中出错我输入的内容与我从终端输入ldif文件时输入的相同。我的bean配置是

<!-- ldap template -->
    <ldap:context-source id="contextSource" url="ldap://localhost:389"
        base="dc=test,dc=com" username="cn=admin" password="pass000" />

    <ldap:ldap-template id="ldapTemplate"
        context-source-ref="contextSource" />

    <bean id="personDao" class="com.cheasyy.cofinding.dao.PersonDaoImpl">
        <property name="ldapTemplate" ref="ldapTemplate" />
    </bean>

它给出了错误

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
    org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:894)
    org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
    com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:205)
    com.thetransactioncompany.cors.CORSFilter.doFilter(CORSFilter.java:266)
root cause

org.springframework.ldap.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]; nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
    org.springframework.ldap.support.LdapUtils.convertLdapException(LdapUtils.java:191)
    org.springframework.ldap.core.support.AbstractContextSource.createContext(AbstractContextSource.java:356)
    org.springframework.ldap.core.support.AbstractContextSource.doGetContext(AbstractContextSource.java:140)

如果使用相同的凭据,我可以从终端添加ldif文件,那么为什么不使用我的spring应用程序?他们的配置中是否缺少任何内容?

1 个答案:

答案 0 :(得分:0)

&#39;用户名&#39; DN需要是管理员用户的完整DN,包括基础;在你的情况下:

RTB.SelectedXXX

管理员用户位于LDAP树的不同部分,而不是您希望从中创建操作的基本DN,这种情况并不少见。

相关问题