code: public static void setupSecurityProperties(Hashtable<String,Object>  env,
     String userDN, char pwd[])
  
     {
  	        
        if(userDN != null)
        {
            if (pwd == null)
                pwd = new char[0];
  
            env.put("java.naming.security.authentication", "simple");
  
            env.put("java.naming.security.principal", userDN);
  
            env.put("java.naming.security.credentials", new String(pwd));
      	  
        }
        
        boolean useSslConfigFactory = Config.getPropertyBoolean(LDAP_USE_SSL_CONFIG_FACTORY_PROP,false).booleanValue();
        
        String url = (String)env.get(LDAP.JAVA_NAMING_PROVIDER_URL);
        if(url != null && url.trim().toLowerCase().startsWith("ldaps")
           && useSslConfigFactory)
        {
      	  	env.put("java.naming.security.protocol","ssl");
      	  	env.put("java.naming.ldap.factory.socket", SSLConfigSocketFactory.class.getName());
        }
  
     }
docs: --------------------------------------------