# File lib/activeldap/base.rb, line 355
    def Base.reconnect(force=false)
      unless @@config
        @@logger.error('Ignoring force: Base.reconnect called before Base.connect') if force
        @@logger.debug('Base.reconnect called before Base.connect - calling Base.connect')
        Base.connect
        return true
      end
      not_connected = true
      while not_connected
        if Base.can_reconnect?
          @@logger.debug('Attempting to reconnect')
          Base.close()

          # Reset the attempts if this was forced.
          @@reconnect_attempts = 0 if force
          @@reconnect_attempts += 1 if @@config[:retries] >= 0
          begin
            do_connect() 
            not_connected = false
          rescue => detail
            @@logger.error("Reconnect to server failed: #{detail.exception}")
            @@logger.error("Reconnect to server failed backtrace: #{detail.backtrace}")
            # Do not loop if forced
            raise ConnectionError, detail.message if force
          end
        else
          # Raise a warning
          raise ConnectionError, 'Giving up trying to reconnect to LDAP server.'
        end

        # Sleep before looping
        sleep @@config[:retry_wait]
      end
      return true
    end