Module: ActiveLdap::Connection::ClassMethods

### Home Classes Methods

### In Files

- lib/active_ldap/connection.rb

### Methods

- #active_connection_name
- #clear_active_connection_name
- #clear_active_connections!
- #connected?
- #connection
- #connection=
- #default_adapter
- #establish_connection
- #instantiate_adapter
- #remove_active_connections!
- #remove_connection
- #reset_runtime
- #retrieve_connection
- #schema
- #setup_connection
- #single_threaded_active_connections
- #thread_safe_active_connections

### Files

- USAGE

### Class/Module Index

Quicksearch

- ActiveLdap
- ActiveLdap::ActionController
- ActiveLdap::ActionController::LdapBenchmarking
- ActiveLdap::Acts
- ActiveLdap::Acts::Tree
- ActiveLdap::Acts::Tree::ClassMethods
- ActiveLdap::Adapter
- ActiveLdap::Adapter::Base
- ActiveLdap::Adapter::Jndi
- ActiveLdap::Adapter::JndiConnection
- ActiveLdap::Adapter::JndiConnection::ModifyRecord
- ActiveLdap::Adapter::JndiConnection::Scope
- ActiveLdap::Adapter::Ldap
- ActiveLdap::Adapter::Ldap::Method
- ActiveLdap::Adapter::Ldap::Method::Base
- ActiveLdap::Adapter::Ldap::Method::Plain
- ActiveLdap::Adapter::Ldap::Method::SSL
- ActiveLdap::Adapter::Ldap::Method::TLS
- ActiveLdap::Adapter::NetLdap
- ActiveLdap::Association
- ActiveLdap::Association::BelongsTo
- ActiveLdap::Association::BelongsToMany
- ActiveLdap::Association::Children
- ActiveLdap::Association::Collection
- ActiveLdap::Association::HasMany
- ActiveLdap::Association::HasManyUtils
- ActiveLdap::Association::HasManyWrap
- ActiveLdap::Association::Proxy
- ActiveLdap::Associations
- ActiveLdap::Associations::ClassMethods
- ActiveLdap::AttributeMethods
- ActiveLdap::AttributeMethods::BeforeTypeCast
- ActiveLdap::AttributeMethods::Dirty
- ActiveLdap::AttributeMethods::Query
- ActiveLdap::AttributeMethods::Read
- ActiveLdap::AttributeMethods::Write
- ActiveLdap::Attributes
- ActiveLdap::Attributes::ClassMethods
- ActiveLdap::Attributes::Normalizable
- ActiveLdap::Callbacks
- ActiveLdap::Callbacks::ClassMethods
- ActiveLdap::Command
- ActiveLdap::Compatible
- ActiveLdap::Configuration
- ActiveLdap::Configuration::ClassMethods
- ActiveLdap::Connection
- ActiveLdap::Connection::ClassMethods
- ActiveLdap::DN
- ActiveLdap::DistinguishedName
- ActiveLdap::DistinguishedName::Parser
- ActiveLdap::EntryAttribute
- ActiveLdap::Escape
- ActiveLdap::Generators
- ActiveLdap::Generators::ModelGenerator
- ActiveLdap::Generators::ScaffoldGenerator
- ActiveLdap::GetText
- ActiveLdap::GetText::Parser
- ActiveLdap::GetTextSupport
- ActiveLdap::Helper
- ActiveLdap::HumanReadable
- ActiveLdap::HumanReadable::ClassMethods
- ActiveLdap::LDIF
- ActiveLdap::LdapError
- ActiveLdap::Ldif
- ActiveLdap::Ldif::AddRecord
- ActiveLdap::Ldif::Attribute
- ActiveLdap::Ldif::Attributes
- ActiveLdap::Ldif::ChangeRecord
- ActiveLdap::Ldif::ChangeRecord::Control
- ActiveLdap::Ldif::ContentRecord
- ActiveLdap::Ldif::DeleteRecord
- ActiveLdap::Ldif::ModifyDNRecord
- ActiveLdap::Ldif::ModifyNameRecord
- ActiveLdap::Ldif::ModifyRDNRecord
- ActiveLdap::Ldif::ModifyRecord
- ActiveLdap::Ldif::ModifyRecord::AddOperation
- ActiveLdap::Ldif::ModifyRecord::DeleteOperation
- ActiveLdap::Ldif::ModifyRecord::Operation
- ActiveLdap::Ldif::ModifyRecord::ReplaceOperation
- ActiveLdap::Ldif::Parser
- ActiveLdap::Ldif::Record
- ActiveLdap::Ldif::Scanner
- ActiveLdap::LogSubscriber
- ActiveLdap::ObjectClass
- ActiveLdap::ObjectClass::ClassMethods
- ActiveLdap::Operations
- ActiveLdap::Operations::ClassOnlyDelete
- ActiveLdap::Operations::ClassOnlyUpdate
- ActiveLdap::Operations::Common
- ActiveLdap::Operations::Delete
- ActiveLdap::Operations::Find
- ActiveLdap::Operations::LDIF
- ActiveLdap::Operations::LDIF::AddRecordLoadable
- ActiveLdap::Operations::LDIF::ContentRecordLoadable
- ActiveLdap::Operations::LDIF::DeleteRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyNameRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::AddOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::DeleteOperationModifiable
- ActiveLdap::Operations::LDIF::ModifyRecordLoadable::ReplaceOperationModifiable
- ActiveLdap::Operations::Update
- ActiveLdap::Persistence
- ActiveLdap::Populate
- ActiveLdap::Railtie
- ActiveLdap::Railties
- ActiveLdap::Railties::ControllerRuntime
- ActiveLdap::Railties::ControllerRuntime::ClassMethods
- ActiveLdap::Schema
- ActiveLdap::Schema::Attribute
- ActiveLdap::Schema::Entry
- ActiveLdap::Schema::ObjectClass
- ActiveLdap::Schema::Syntax
- ActiveLdap::Schema::Syntaxes
- ActiveLdap::Schema::Syntaxes::Base
- ActiveLdap::Schema::Syntaxes::BitString
- ActiveLdap::Schema::Syntaxes::Boolean
- ActiveLdap::Schema::Syntaxes::CountryString
- ActiveLdap::Schema::Syntaxes::DirectoryString
- ActiveLdap::Schema::Syntaxes::DistinguishedName
- ActiveLdap::Schema::Syntaxes::GeneralizedTime
- ActiveLdap::Schema::Syntaxes::Integer
- ActiveLdap::Schema::Syntaxes::JPEG
- ActiveLdap::Schema::Syntaxes::NameAndOptionalUID
- ActiveLdap::Schema::Syntaxes::NumericString
- ActiveLdap::Schema::Syntaxes::OID
- ActiveLdap::Schema::Syntaxes::OtherMailbox
- ActiveLdap::Schema::Syntaxes::PostalAddress
- ActiveLdap::Schema::Syntaxes::PrintableString
- ActiveLdap::Schema::Syntaxes::TelephoneNumber
- ActiveLdap::UserPassword
- ActiveLdap::UserPassword::Salt
- ActiveLdap::Validations
- ActiveLdap::XML
- ActiveLdap::Xml
- ActiveLdap::Xml::Serializer
- LDAP
- LDAP::Conn
- LDAP::Mod
- Net
- Net::LDAP
- Net::LDAP::Entry
- ActionView
- ActionView::Base
- URI
- URI::LDAPS
- Object
- Timeout

No matching classes.

# ActiveLdap::Connection::ClassMethods

### Public Instance Methods

active_connection_name() click to toggle source

    # File lib/active_ldap/connection.rb, line 37
    def active_connection_name
      @active_connection_name ||= determine_active_connection_name
    end

clear_active_connection_name() click to toggle source

    # File lib/active_ldap/connection.rb, line 55
    def clear_active_connection_name
      @active_connection_name = nil
      ObjectSpace.each_object(Class) do |klass|
        if klass < self and !klass.name.blank?
          klass.instance_variable_set("@active_connection_name", nil)
        end
      end
    end

clear_active_connections!() click to toggle source

    # File lib/active_ldap/connection.rb, line 47
    def clear_active_connections!
      connections = active_connections
      connections.each do |key, connection|
        connection.disconnect!
      end
      connections.clear
    end

connected?() click to toggle source

    # File lib/active_ldap/connection.rb, line 111
    def connected?
      active_connections[active_connection_name] ? true : false
    end

connection() click to toggle source

    # File lib/active_ldap/connection.rb, line 64
    def connection
      conn = nil
      @active_connection_name ||= nil
      if @active_connection_name
        conn = active_connections[@active_connection_name]
      end
      unless conn
        conn = retrieve_connection
        active_connections[@active_connection_name] = conn
      end
      conn
    end

connection=(adapter) click to toggle source

    # File lib/active_ldap/connection.rb, line 77
    def connection=(adapter)
      if adapter.is_a?(Adapter::Base)
        active_connections[active_connection_name] = adapter
      elsif adapter.is_a?(Hash)
        config = adapter
        self.connection = instantiate_adapter(config)
      elsif adapter.nil?
        raise ConnectionNotSetup
      else
        setup_connection(adapter)
      end
    end

default_adapter() click to toggle source

    # File lib/active_ldap/connection.rb, line 107
    def default_adapter
      @@default_adapter ||= guess_available_adapter
    end

establish_connection(config=nil) click to toggle source

    # File lib/active_ldap/connection.rb, line 154
    def establish_connection(config=nil)
      message =
        _("ActiveLdap::Connection.establish_connection has been deprecated "              "since 1.1.0. "              "Please use ActiveLdap::Connection.setup_connection instead.")
      ActiveSupport::Deprecation.warn(message)
      setup_connection(config)
    end

instantiate_adapter(config) click to toggle source

    # File lib/active_ldap/connection.rb, line 90
    def instantiate_adapter(config)
      adapter = (config[:adapter] || default_adapter)
      normalized_adapter = adapter.downcase.gsub(/-/, "_")
      adapter_method = "#{normalized_adapter}_connection"
      unless Adapter::Base.respond_to?(adapter_method)
        raise AdapterNotFound.new(adapter)
      end
      if config.has_key?(:ldap_scope)
        message = _(":ldap_scope connection option is deprecated. "                        "Use :scope instead.")
        ActiveSupport::Deprecation.warn(message)
        config[:scope] ||= config.delete(:ldap_scope)
      end
      config = remove_connection_related_configuration(config)
      Adapter::Base.send(adapter_method, config)
    end

remove_active_connections!() click to toggle source

    # File lib/active_ldap/connection.rb, line 41
    def remove_active_connections!
      active_connections.keys.each do |key|
        remove_connection(key)
      end
    end

remove_connection(klass_or_key=self) click to toggle source

    # File lib/active_ldap/connection.rb, line 130
    def remove_connection(klass_or_key=self)
      if klass_or_key.is_a?(Module)
        key = active_connection_key(klass_or_key)
      else
        key = klass_or_key
      end
      config = configuration(key)
      conn = active_connections[key]
      remove_configuration_by_configuration(config)
      active_connections.delete_if {|_key, value| value == conn}
      conn.disconnect! if conn
      config
    end

reset_runtime() click to toggle source

    # File lib/active_ldap/connection.rb, line 168
    def reset_runtime
      active_connections.inject(0) do |result, (name, connection)|
        _ = name # for suppress a warning on Ruby 1.9.3
        result + connection.reset_runtime
      end
    end

retrieve_connection() click to toggle source

    # File lib/active_ldap/connection.rb, line 115
    def retrieve_connection
      conn = nil
      name = active_connection_name
      raise ConnectionNotSetup unless name
      conn = active_connections[name]
      if conn.nil?
        config = configuration(name)
        raise ConnectionNotSetup unless config
        self.connection = config
        conn = active_connections[name]
      end
      raise ConnectionNotSetup if conn.nil?
      conn
    end

schema() click to toggle source

Return the schema object

    # File lib/active_ldap/connection.rb, line 164
    def schema
      connection.schema
    end

setup_connection(config=nil) click to toggle source

    # File lib/active_ldap/connection.rb, line 144
    def setup_connection(config=nil)
      config = ensure_configuration(config)
      remove_connection

      clear_active_connection_name
      key = active_connection_key
      @active_connection_name = key
      define_configuration(key, merge_configuration(config))
    end

single_threaded_active_connections() click to toggle source

    # File lib/active_ldap/connection.rb, line 15
    def single_threaded_active_connections
      @@active_connections
    end

thread_safe_active_connections() click to toggle source

    # File lib/active_ldap/connection.rb, line 11
    def thread_safe_active_connections
      @@active_connections[Thread.current.object_id] ||= {}
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.