title: How to connect to Ldap server using java?
body: <p>Please find my below code and Help me connect to LDAP.</p>
  
  <p>My code below :</p>
  
  <pre><code> 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.214:389");
   environment.put(Context.SECURITY_AUTHENTICATION, "simple");
   environment.put(Context.SECURITY_PRINCIPAL, "CN=Administrator,CN=Users,DC=estsecondary,DC=com");
   environment.put(Context.SECURITY_CREDENTIALS, "*****8");
   try {
       LdapContext ctx = new InitialLdapContext(environment, null); 
   }catch (AuthenticationNotSupportedException exception) {
       System.out.println("The authentication is not supported by the server");
   } catch (AuthenticationException exception){
       System.out.println("Incorrect password or username");
   }catch (NamingException exception){
       System.out.println("Error when trying to create the context");
   }
  </code></pre>
  
  <p>But I'm not able to connect. I'm getting "The authentication is not supported by the server".Please find my LDAP structure below.</p>
  
  <p><a href="https://i.stack.imgur.com/nGBKJ.jpg" rel="nofollow noreferrer">enter image description here</a></p>