title: Spring Security AD LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E8
body: <p>I am trying to connect Ldap from spring security, getting connection errors. Could some one suggest what is wrong with this configuration, </p>
  
  <blockquote>
    <p>UsernamePasswordAuthenticationFilter - An internal error occurred while trying to authenticate the user.
        org.springframework.security.authentication.InternalAuthenticationServiceException: Uncategorized exception occured during LDAP processing; nested exception is javax.naming.NamingException: [LDAP: error code 1 - 000004DC: LdapErr: DSID-0C0906E8, comment: In order to perform this operation a successful bind must be completed on the connection., data 0, v1db1]; remaining name 'ou=Users,dc=aaa,dc=bbb,dc=ccc,dc=dddd'
        at org.springframework.security.ldap.authentication.LdapAuthenticationProvider.doAuthentication(LdapAuthenticationProvider.java:191)</p>
  </blockquote>
  
  <p>config file has,</p>
  
  <pre><code>&lt;sec:authentication-manager alias="myAuthenticationManager"&gt;
      &lt;sec:authentication-provider ref="myAuthenticationProvider"/&gt;
  &lt;/sec:authentication-manager&gt;
  
  &lt;bean id="myAuthenticationProvider" class="org.springframework.security.ldap.authentication.LdapAuthenticationProvider"&gt;
      &lt;constructor-arg ref="ldapBindAuthenticator"/&gt;
      &lt;constructor-arg ref="ldapAuthoritiesPopulator"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="ldapBindAuthenticator" class="org.springframework.security.ldap.authentication.BindAuthenticator"&gt;
      &lt;constructor-arg ref="contextSource" /&gt;
      &lt;property name="userSearch" ref="userSearch"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="userSearch" class="org.springframework.security.ldap.search.FilterBasedLdapUserSearch"&gt;
      &lt;constructor-arg index="0" value="ou=Users,dc=aaa,dc=bbb,dc=ccc,dc=dddd"/&gt;
      &lt;constructor-arg index="1" value="(sAMAccountName={0})"/&gt;
      &lt;constructor-arg index="2" ref="contextSource"/&gt;
      &lt;property name="searchSubtree" value="true"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="ldapAuthoritiesPopulator" class="com.xxxx.MyLdapAuthoritiesPopulator"&gt;
      &lt;property name="userDao" ref="userDao"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="contextSource" class="org.springframework.security.ldap.DefaultSpringSecurityContextSource"&gt;
      &lt;constructor-arg value="ldaps://aaa.com:123/DC=aa,DC=bb,DC=cc,DC=dd"/&gt;
      &lt;property name="base" value="DC=aa,DC=bb,DC=cc,DC=dd" /&gt;
      &lt;!-- &lt;property name="anonymousReadOnly" value="true"/&gt; --&gt;
  
  &lt;/bean&gt;
  </code></pre>