You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: connection.rb
    path of file: ./repos/Portus/lib/portus/ldap
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

require "portus/ldap/adapter"

module Portus
  module LDAP
    # Connection holds a set of methods which are responsible for binding to the
    # LDAP server by considering
    
      def bind_as(connection, cfg)
        raise ::Portus::LDAP::Error, "LDAP is disabled" unless cfg.enabled?
        raise ::Portus::LDAP::Error, "Some parameters are missing" unless cfg.initialized?

        res, admin = bind_admin_or_user(connection, cfg)
        binding_failed!(connection, cfg.username) unless res
        [res, admin]
      end