2016-03-15 179 views
0

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

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

它问我密码。我输入了pass000,它添加了新的entry.its工作正常.i可以添加从终端搜索记录。现在我尝试从我的春天的应用程序。我添加了依赖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) 

如果用相同的凭据,我可以用我的Spring应用程序?他们是在什么配置中缺少来自终端添加LDIF文件,那么为什么不呢?

回答

0

'用户名'DN必须是管理员用户的完整DN,包括基础;你的情况:

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

的情况并不少见admin用户将设在LDAP树比你想你的业务发起的基本DN的不同部分。