Module ActiveLdap::Connection::ClassMethods
In: lib/active_ldap/connection.rb
Error DeleteError LdapError AdapterNotSpecified OperationNotPermitted RequiredAttributeMissed LdifInvalid AttributeAssignmentError RequiredObjectClassMissed DistinguishedNameNotSetError StrongAuthenticationRequired ConnectionError SaveError EntryNotFound AuthenticationError EntryNotSaved UnknownAttribute ConnectionNotEstablished TimeoutError ConfigurationError AdapterNotFound DistinguishedNameInvalid ObjectClassError EntryInvalid EntryAlreadyExist Base DistinguishedName Ldif Reloadable::Deprecated Reloadable::Subclasses Enumerable Collection StandardError Children HasMany HasManyWrap BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update GetText Parser GetTextSupport Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Ldap NetLdap Normalize ActiveRecord::Callbacks ActiveRecord::Validations Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/ldif.rb lib/active_ldap/distinguished_name.rb lib/active_ldap/ldap_error.rb ClassMethods Associations ClassMethods HumanReadable 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/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb HasManyUtils Association ClassMethods Tree Acts Common LDIF Delete Find Update Operations lib/active_ldap/get_text/parser.rb GetText ClassMethods Configuration Command lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb Adapter GetTextSupport Normalize ClassMethods Attributes Escape Callbacks ClassMethods ObjectClass Helper Validations ClassMethods Connection GetTextFallback Populate Salt UserPassword ActiveLdap dot/m_40_0.png

Methods

Public Instance methods

[Source]

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

[Source]

    # File lib/active_ldap/connection.rb, line 55
55:       def clear_active_connection_name
56:         @active_connection_name = nil
57:         ObjectSpace.each_object(Class) do |klass|
58:           if klass < self and !klass.name.empty?
59:             klass.instance_variable_set("@active_connection_name", nil)
60:           end
61:         end
62:       end

[Source]

    # File lib/active_ldap/connection.rb, line 47
47:       def clear_active_connections!
48:         connections = active_connections
49:         connections.each do |key, connection|
50:           connection.disconnect!
51:         end
52:         connections.clear
53:       end

[Source]

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

[Source]

    # File lib/active_ldap/connection.rb, line 64
64:       def connection
65:         conn = nil
66:         @active_connection_name ||= nil
67:         if @active_connection_name
68:           conn = active_connections[@active_connection_name]
69:         end
70:         unless conn
71:           conn = retrieve_connection
72:           active_connections[@active_connection_name] = conn
73:         end
74:         conn
75:       end

[Source]

    # File lib/active_ldap/connection.rb, line 77
77:       def connection=(adapter)
78:         if adapter.is_a?(Adapter::Base)
79:           active_connections[active_connection_name] = adapter
80:         elsif adapter.is_a?(Hash)
81:           config = adapter
82:           self.connection = instantiate_adapter(config)
83:         elsif adapter.nil?
84:           raise ConnectionNotEstablished
85:         else
86:           establish_connection(adapter)
87:         end
88:       end

[Source]

     # File lib/active_ldap/connection.rb, line 140
140:       def establish_connection(config=nil)
141:         config = ensure_configuration(config)
142:         remove_connection
143: 
144:         clear_active_connection_name
145:         key = active_connection_key
146:         @active_connection_name = key
147:         define_configuration(key, merge_configuration(config))
148:       end

[Source]

     # File lib/active_ldap/connection.rb, line 90
 90:       def instantiate_adapter(config)
 91:         adapter = (config[:adapter] || "ldap")
 92:         normalized_adapter = adapter.downcase.gsub(/-/, "_")
 93:         adapter_method = "#{normalized_adapter}_connection"
 94:         unless Adapter::Base.respond_to?(adapter_method)
 95:           raise AdapterNotFound.new(adapter)
 96:         end
 97:         if config.has_key?(:ldap_scope)
 98:           logger.warning do
 99:             _(":ldap_scope connection option is deprecated. Use :scope instead.")
100:           end
101:           config[:scope] ||= config.delete(:ldap_scope)
102:         end
103:         config = remove_connection_related_configuration(config)
104:         Adapter::Base.send(adapter_method, config)
105:       end

[Source]

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

[Source]

     # File lib/active_ldap/connection.rb, line 126
126:       def remove_connection(klass_or_key=self)
127:         if klass_or_key.is_a?(Module)
128:           key = active_connection_key(klass_or_key)
129:         else
130:           key = klass_or_key
131:         end
132:         config = configuration(key)
133:         conn = active_connections[key]
134:         remove_configuration_by_configuration(config)
135:         active_connections.delete_if {|key, value| value == conn}
136:         conn.disconnect! if conn
137:         config
138:       end

[Source]

     # File lib/active_ldap/connection.rb, line 111
111:       def retrieve_connection
112:         conn = nil
113:         name = active_connection_name
114:         raise ConnectionNotEstablished unless name
115:         conn = active_connections[name]
116:         if conn.nil?
117:           config = configuration(name)
118:           raise ConnectionNotEstablished unless config
119:           self.connection = config
120:           conn = active_connections[name]
121:         end
122:         raise ConnectionNotEstablished if conn.nil?
123:         conn
124:       end

Return the schema object

[Source]

     # File lib/active_ldap/connection.rb, line 151
151:       def schema
152:         connection.schema
153:       end

[Source]

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

[Source]

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

Private Instance methods

[Source]

     # File lib/active_ldap/connection.rb, line 156
156:       def active_connection_key(k=self)
157:         k.name.empty? ? k.object_id : k.name
158:       end

[Source]

     # File lib/active_ldap/connection.rb, line 171
171:       def clear_all_cached_connections!
172:         if @@allow_concurrency
173:           @@active_connections.each_value do |connection_hash_for_thread|
174:             connection_hash_for_thread.each_value {|conn| conn.disconnect!}
175:             connection_hash_for_thread.clear
176:           end
177:         else
178:           @@active_connections.each_value {|conn| conn.disconnect!}
179:         end
180:         @@active_connections.clear
181:       end

[Source]

     # File lib/active_ldap/connection.rb, line 160
160:       def determine_active_connection_name
161:         key = active_connection_key
162:         if active_connections[key] or configuration(key)
163:           key
164:         elsif self == ActiveLdap::Base
165:           nil
166:         else
167:           superclass.active_connection_name
168:         end
169:       end

[Validate]