Module ActiveLdap::Connection::ClassMethods
In: lib/active_ldap/connection.rb
Error DeleteError AdapterNotSpecified OperationNotPermitted LdapError RequiredAttributeMissed AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Reloadable::Deprecated Base Reloadable::Subclasses Enumerable Collection StandardError HasMany HasManyWrap BelongsToMany Proxy BelongsTo Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap ActiveRecord::Callbacks ActiveRecord::Validations Schema DistinguishedName lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/has_many.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb Association ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/base.rb Adapter ClassMethods Attributes ClassMethods ObjectClass Callbacks ClassMethods Connection Validations Salt UserPassword ActiveLdap dot/m_26_0.png

Methods

Public Instance methods

[Source]

    # File lib/active_ldap/connection.rb, line 14
14:       def active_connection_name
15:         @active_connection_name ||= determine_active_connection_name
16:       end

[Source]

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

[Source]

    # File lib/active_ldap/connection.rb, line 26
26:       def clear_active_connection_name
27:         @active_connection_name = nil
28:         ObjectSpace.each_object(Class) do |klass|
29:           if klass < self and !klass.name.empty?
30:             klass.instance_variable_set("@active_connection_name", nil)
31:           end
32:         end
33:       end

[Source]

    # File lib/active_ldap/connection.rb, line 18
18:       def clear_active_connections!
19:         connections = active_connections
20:         connections.each do |key, connection|
21:           connection.disconnect!
22:         end
23:         connections.clear
24:       end

[Source]

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

[Source]

    # File lib/active_ldap/connection.rb, line 35
35:       def connection
36:         conn = nil
37:         @active_connection_name ||= nil
38:         if @active_connection_name
39:           conn = active_connections[@active_connection_name]
40:         end
41:         unless conn
42:           conn = retrieve_connection
43:           active_connections[@active_connection_name] = conn
44:         end
45:         conn
46:       end

[Source]

    # File lib/active_ldap/connection.rb, line 48
48:       def connection=(adapter)
49:         if adapter.is_a?(Adapter::Base)
50:           @schema = nil
51:           active_connections[active_connection_name] = adapter
52:         elsif adapter.is_a?(Hash)
53:           config = adapter
54:           adapter = (config[:adapter] || "ldap")
55:           normalized_adapter = adapter.downcase.gsub(/-/, "_")
56:           adapter_method = "#{normalized_adapter}_connection"
57:           unless Adapter::Base.respond_to?(adapter_method)
58:             raise AdapterNotFound.new(adapter)
59:           end
60:           config = remove_connection_related_configuration(config)
61:           self.connection = Adapter::Base.send(adapter_method, config)
62:         elsif adapter.nil?
63:           raise ConnectionNotEstablished
64:         else
65:           establish_connection(adapter)
66:         end
67:       end

[Source]

     # File lib/active_ldap/connection.rb, line 98
 98:       def establish_connection(config=nil)
 99:         config = ensure_configuration(config)
100:         remove_connection
101: 
102:         clear_active_connection_name
103:         key = active_connection_key
104:         @active_connection_name = key
105:         define_configuration(key, merge_configuration(config))
106:       end

[Source]

    # File lib/active_ldap/connection.rb, line 88
88:       def remove_connection(klass=self)
89:         key = active_connection_key(klass)
90:         config = configuration(key)
91:         conn = active_connections[key]
92:         remove_configuration_by_configuration(config)
93:         active_connections.delete_if {|key, value| value == conn}
94:         conn.disconnect! if conn
95:         config
96:       end

[Source]

    # File lib/active_ldap/connection.rb, line 73
73:       def retrieve_connection
74:         conn = nil
75:         name = active_connection_name
76:         raise ConnectionNotEstablished unless name
77:         conn = active_connections[name]
78:         if conn.nil?
79:           config = configuration(name)
80:           raise ConnectionNotEstablished unless config
81:           self.connection = config
82:           conn = active_connections[name]
83:         end
84:         raise ConnectionNotEstablished if conn.nil?
85:         conn
86:       end

Return the schema object

[Source]

     # File lib/active_ldap/connection.rb, line 109
109:       def schema
110:         @schema ||= connection.schema
111:       end

Private Instance methods

[Source]

     # File lib/active_ldap/connection.rb, line 114
114:       def active_connection_key(k=self)
115:         k.name.empty? ? k.object_id : k.name
116:       end

[Source]

     # File lib/active_ldap/connection.rb, line 118
118:       def determine_active_connection_name
119:         key = active_connection_key
120:         if active_connections[key] or configuration(key)
121:           key
122:         elsif self == ActiveLdap::Base
123:           nil
124:         else
125:           superclass.active_connection_name
126:         end
127:       end

[Validate]