title: ldap Authentication Error from java program
body: <pre><code>public static void main(String[] args)
  {
  
  
      // Setup environment for authenticating
  
      Hashtable&lt;String, String&gt; environment = 
          new Hashtable&lt;String, String&gt;();
  
      environment.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
  
      environment.put(Context.PROVIDER_URL,"ldap://192.168.0.100:389");
  
      environment.put(Context.SECURITY_AUTHENTICATION,"simple");
  
      environment.put(Context.SECURITY_PRINCIPAL,"uid=dilip.duraiswamy,dc=xxxx,dc=local");
  
      environment.put(Context.SECURITY_CREDENTIALS,"xxxx");
  
      try
      {
          DirContext authContext = 
              new InitialDirContext(environment);
  
          // user is authenticated
          System.out.println("USER IS AUTHETICATED");
  
      }
      catch (AuthenticationException ex)
      {
  
          // Authentication failed
          System.out.println("AUTH FAILED : "+ex );
  
      }
      catch (NamingException ex)
      {
          ex.printStackTrace();
      }
  }
  </code></pre>
  
  <p>Getting the error as 
  javax.naming.AuthenticationException: [LDAP: error code 49 - 80090308: LdapErr: DSID-0C09042F, comment: AcceptSecurityContext error, data 52e, v2580</p>