title: How to determine if the LDAP server allows anonymous binding or not?
body: <p>Using java when i try to connect to an LDAP server which does not allow anonymous binding i don't get any errors. But when i use a client to connect to that server anonymously, i am not able to. Is there a way to identify if the LDAP server supports anonymous binding or not in java ?</p>
  
  <pre><code>// Set up environment for creating initial context
  Hashtable&lt;String, Object&gt; env = new Hashtable&lt;String, Object&gt;();
  env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
  env.put(Context.PROVIDER_URL, "ldap://"+host+":"+port+"/");     
  env.put(Context.SECURITY_PRINCIPAL, dn);
  env.put(Context.REFERRAL, "follow");
  env.put(VsomConstants.LDAP_CONNECT_TIMEOUT, SystemPreferencesHelper.getLdapConnectionTimeOut().toString());
  
  env.put(Context.SECURITY_AUTHENTICATION, "none");
  
  // Create initial context
  ctx = new InitialDirContext(env);
  </code></pre>