title: How to connect with an external/online LDAP server using Spring Boot?
body: <p>I am trying to integrate LDAP based login in my Spring Boot application.</p>
  
  <p>As initial step, I am trying to use this LDAP server (<a href="http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/" rel="nofollow noreferrer">http://www.forumsys.com/tutorials/integration-how-to/ldap/online-ldap-test-server/</a>).</p>
  
  <p>But, I am unable to successfully connect with the server and getting this error.</p>
  
  <pre><code>nested exception is javax.naming.AuthenticationException: [LDAP: error code 49 - Invalid Credentials]
  </code></pre>
  
  <p>I am using this information in configuration class.</p>
  
  <pre><code>authenticationManagerBuilder.ldapAuthentication()
              .contextSource().url("ldap://ldap.forumsys.com:389/dc=example,dc=com")
              .managerDn("cn=read-only-admin,dc=example,dc=com").managerPassword("password")
              .and()
              .userSearchBase("ou=mathematicians")
              .groupSearchBase("ou=mathematicians")
              .userSearchFilter("(cn={0})");
  </code></pre>
  
  <p>And this is my application.properties file for this project.</p>
  
  <pre><code>spring.ldap.urls=ldap.forumsys.com:389
  spring.ldap.base=cn=read-only-admin,dc=example,dc=com
  spring.ldap.password=password
  </code></pre>
  
  <p>Can anyone provide a working configuration for a Spring Boot application using an LDAP server?</p>