title: LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1
body: <blockquote>
    <p>LDAP: error code 49 - 80090308: LdapErr: DSID-0C0903A9, comment: AcceptSecurityContext error, data 52e, v1db1</p>
  </blockquote>
  
  <p>I know "52e" code is when username is valid, but password is invalid. I am using the same user  name and password in my apache studio, I was able to establish the connection succesfully to LDAP.</p>
  
  <p><strong>Here is my java code</strong> </p>
  
  <pre><code>    String userName = "*******";
      String password = "********";
      String base ="DC=PSLTESTDOMAIN,DC=LOCAL";
      String dn = "cn=" + userName + "," + base;  
      Hashtable env = new Hashtable();
      env.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
      env.put(Context.PROVIDER_URL, "ldap://******");
      env.put(Context.SECURITY_AUTHENTICATION, "simple");
      env.put(Context.SECURITY_PRINCIPAL, dn);
      env.put(Context.SECURITY_CREDENTIALS, password);
      LDAPAuthenticationService ldap = new LDAPAuthenticationService();
     // LdapContext ctx;
      DirContext ctx = null;
      try {
          ctx = new InitialDirContext(env);
  </code></pre>
  
  <p><strong>My error is on this line</strong>: <code>ctx = new InitialDirContext(env);</code></p>
  
  <p>I do not know what exactly is causing this error. </p>