0 Replies Latest reply: Nov 22, 2012 3:22 AM by WangZi RSS

    How to connect to AD/ldap with TLS

    WangZi
      I have a windows 2008 R2 server installed AD.

      After server hardening. I am not able to connect to the AD. After I do the search and find , any none-secured ldap connection will failed.



      I am using the following to connect


                String ldapHost = "ldap://Test.local:389";
                
                Properties props = new Properties();
                props.put(Context.INITIAL_CONTEXT_FACTORY,
                          "com.sun.jndi.ldap.LdapCtxFactory");

                //props.put(Context.SECURITY_PROTOCOL, "ssl");
                props.put(Context.SECURITY_AUTHENTICATION, "simple");
                props.put(Context.SECURITY_PRINCIPAL, "" + userName);
                props.put(Context.SECURITY_CREDENTIALS, "" + password);
                props.put(Context.PROVIDER_URL, ldapHost);
                try {
                     DirContext ctx = new InitialDirContext(props);
                     assertNotNull(ctx);
                     return true;
                } catch (NamingException e) {
                     log.error("Failed Login, login userName:" + userName + ".", e);
                } catch (Exception e){
                     log.error(e, e);
                }



      Here is the error:
      ERROR [main] (LdapTest.java:73) - Failed Login, login userName:test\test.
      javax.naming.AuthenticationNotSupportedException: [LDAP: error code 8 - 00002028: LdapErr: DSID-0C0901FC, comment: The server requires binds to turn on integrity checking if SSL\TLS are not already active on the connection, data 0, v1db1


      Any tips will help. Thank you very much