2016-03-15 176 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的不同部分。