code: public static Connection createConnection(final ConnectionFactory connectionFactory) throws LdapException {
          val c = connectionFactory.getConnection();
          if (!c.isOpen()) {
              c.open();
          }
          return c;
      }
docs: Gets connection from the factory.
  Opens the connection if needed.
  
  @param connectionFactory the connection factory
  @return the connection
  @throws LdapException the ldap exception