Module ActiveLdap::Connection::ClassMethods
In: lib/active_ldap/connection.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired AdapterNotFound ConnectionNotEstablished TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError DistinguishedNameInvalid DistinguishedName Base Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasManyWrap HasMany BelongsToMany Proxy BelongsTo Common Find LDIF Delete Update Normalizable GetText Parser ActiveRecord::Callbacks ActiveRecord::Validations Base\n[lib/active_ldap/adapter/base.rb\nlib/active_ldap/adapter/jndi.rb\nlib/active_ldap/adapter/ldap.rb\nlib/active_ldap/adapter/net_ldap.rb] Jndi Ldap NetLdap GetTextSupport Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb ClassMethods Associations LdapBenchmarking ActionController Populate lib/active_ldap/association/has_many_wrap.rb lib/active_ldap/association/children.rb lib/active_ldap/association/collection.rb lib/active_ldap/association/proxy.rb lib/active_ldap/association/belongs_to_many.rb lib/active_ldap/association/belongs_to.rb lib/active_ldap/association/has_many.rb HasManyUtils Association ClassMethods Tree Acts Command Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations GetTextSupport Escape ClassMethods Normalizable Attributes ClassMethods Configuration ClassMethods ObjectClass lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks Validations lib/active_ldap/adapter/jndi_connection.rb lib/active_ldap/adapter/net_ldap.rb lib/active_ldap/adapter/ldap.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_44_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 111
111:       def connected?
112:         active_connections[active_connection_name] ? true : false
113:       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 107
107:       def default_adapter
108:         @@default_adapter ||= guess_available_adapter
109:       end

[Source]

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

[Source]

     # File lib/active_ldap/connection.rb, line 90
 90:       def instantiate_adapter(config)
 91:         adapter = (config[:adapter] || default_adapter)
 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 130
130:       def remove_connection(klass_or_key=self)
131:         if klass_or_key.is_a?(Module)
132:           key = active_connection_key(klass_or_key)
133:         else
134:           key = klass_or_key
135:         end
136:         config = configuration(key)
137:         conn = active_connections[key]
138:         remove_configuration_by_configuration(config)
139:         active_connections.delete_if {|key, value| value == conn}
140:         conn.disconnect! if conn
141:         config
142:       end

[Source]

     # File lib/active_ldap/connection.rb, line 159
159:       def reset_runtime
160:         active_connections.inject(0) do |result, (name, connection)|
161:           result + connection.reset_runtime
162:         end
163:       end

[Source]

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

Return the schema object

[Source]

     # File lib/active_ldap/connection.rb, line 155
155:       def schema
156:         connection.schema
157:       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 166
166:       def active_connection_key(k=self)
167:         k.name.empty? ? k.object_id : k.name
168:       end

[Source]

     # File lib/active_ldap/connection.rb, line 181
181:       def clear_all_cached_connections!
182:         if @@allow_concurrency
183:           @@active_connections.each_value do |connection_hash_for_thread|
184:             connection_hash_for_thread.each_value {|conn| conn.disconnect!}
185:             connection_hash_for_thread.clear
186:           end
187:         else
188:           @@active_connections.each_value {|conn| conn.disconnect!}
189:         end
190:         @@active_connections.clear
191:       end

[Source]

     # File lib/active_ldap/connection.rb, line 170
170:       def determine_active_connection_name
171:         key = active_connection_key
172:         if active_connections[key] or configuration(key)
173:           key
174:         elsif self == ActiveLdap::Base
175:           nil
176:         else
177:           superclass.active_connection_name
178:         end
179:       end

[Source]

     # File lib/active_ldap/connection.rb, line 193
193:       def guess_available_adapter
194:         Object.respond_to?(:java) ? "jndi" : "ldap"
195:       end

[Validate]