Module ActiveLdap::Connection::ClassMethods
In: lib/active_ldap/connection.rb
Error AttributeAssignmentError AdapterNotSpecified OperationNotPermitted RequiredObjectClassMissed ConnectionError RequiredAttributeMissed LdifInvalid LdapError DistinguishedNameNotSetError EntryNotFound SaveError StrongAuthenticationRequired NotImplemented AdapterNotFound TimeoutError AuthenticationError AttributeValueInvalid EntryNotSaved DistinguishedNameInputInvalid EntryAlreadyExist ObjectClassError UnknownAttribute EntryInvalid DeleteError ConfigurationError ConnectionNotSetup DistinguishedNameInvalid Schema\n[lib/active_ldap/schema.rb\nlib/active_ldap/schema/syntaxes.rb] Base DistinguishedName Reloadable::Deprecated Reloadable::Subclasses Enumerable Ldif Collection EntryAttribute StandardError Children HasMany HasManyWrap BelongsToMany Proxy BelongsTo Normalizable Common Find LDIF Delete Update 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 Xml JndiConnection lib/active_ldap/distinguished_name.rb lib/active_ldap/base.rb lib/active_ldap/xml.rb lib/active_ldap/schema.rb lib/active_ldap/entry_attribute.rb lib/active_ldap/ldif.rb lib/active_ldap/ldap_error.rb LdapBenchmarking ActionController ClassMethods Associations Compatible ClassMethods Tree Acts 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 Populate Command ClassMethods Normalizable Attributes Escape GetTextSupport Update Common ModifyNameRecordLoadable AddOperationModifiable DeleteOperationModifiable ReplaceOperationModifiable ModifyRecordLoadable DeleteRecordLoadable AddRecordLoadable ContentRecordLoadable LDIF Delete Find Operations ClassMethods Configuration lib/active_ldap/get_text/parser.rb GetText ClassMethods Callbacks ClassMethods ObjectClass 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/base.rb lib/active_ldap/adapter/jndi.rb Adapter Helper GetTextFallback ClassMethods HumanReadable Salt UserPassword ClassMethods Connection ActiveLdap dot/m_45_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.blank?
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 ConnectionNotSetup
85:         else
86:           setup_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 154
154:       def establish_connection(config=nil)
155:         message =
156:           _("ActiveLdap::Connection.establish_connection has been deprecated " \
157:             "since 1.1.0. " \
158:             "Please use ActiveLdap::Connection.setup_connection instead.")
159:         ActiveSupport::Deprecation.warn(message)
160:         setup_connection(config)
161:       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:           message = _(":ldap_scope connection option is deprecated. " \
 99:                       "Use :scope instead.")
100:           ActiveSupport::Deprecation.warn(message)
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 168
168:       def reset_runtime
169:         active_connections.inject(0) do |result, (name, connection)|
170:           result + connection.reset_runtime
171:         end
172:       end

[Source]

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

Return the schema object

[Source]

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

[Source]

     # File lib/active_ldap/connection.rb, line 144
144:       def setup_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 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 175
175:       def active_connection_key(k=self)
176:         k.name.blank? ? k.object_id : k.name
177:       end

[Source]

     # File lib/active_ldap/connection.rb, line 190
190:       def clear_all_cached_connections!
191:         if @@allow_concurrency
192:           @@active_connections.each_value do |connection_hash_for_thread|
193:             connection_hash_for_thread.each_value {|conn| conn.disconnect!}
194:             connection_hash_for_thread.clear
195:           end
196:         else
197:           @@active_connections.each_value {|conn| conn.disconnect!}
198:         end
199:         @@active_connections.clear
200:       end

[Source]

     # File lib/active_ldap/connection.rb, line 179
179:       def determine_active_connection_name
180:         key = active_connection_key
181:         if active_connections[key] or configuration(key)
182:           key
183:         elsif self == ActiveLdap::Base
184:           nil
185:         else
186:           superclass.active_connection_name
187:         end
188:       end

[Source]

     # File lib/active_ldap/connection.rb, line 202
202:       def guess_available_adapter
203:         if Object.respond_to?(:java)
204:           "jndi"
205:         else
206:           ruby_ldap_available = false
207:           $LOAD_PATH.each do |path|
208:             if File.exist?(File.join(path, "ldap", "ldif.rb"))
209:               ruby_ldap_available = true
210:               break
211:             end
212:           end
213:           if !ruby_ldap_available and Object.const_defined?(:Gem)
214:             ruby_ldap_available = Gem.available?("ruby-ldap")
215:           end
216:           if ruby_ldap_available
217:             "ldap"
218:           else
219:             "net-ldap"
220:           end
221:         end
222:       end

[Validate]