# File lib/omniauth/strategies/ldap/adaptor.rb, line 47
        def connect(options={})
          host = options[:host] || @host
          method = ensure_method(options[:method] || @method || :plain)
          port = options[:port] || @port || ensure_port(method)
          @disconnected = false
          @bound = false
          @bind_tried = false

          config = {
            :host => host,
            :port => port,
          }

          config[:encryption] = {:method => method} if method

          @connection, @uri, @with_start_tls = begin
            uri = construct_uri(host, port, method == :simple_tls)
            with_start_tls = method == :start_tls
            [Net::LDAP::Connection.new(config), uri, with_start_tls]
          rescue Net::LDAP::LdapError
            raise ConnectionError, $!.message
          end
        end