Module: ActiveLdap::Connection
- Defined in:
- lib/active_ldap/connection.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #connected? ⇒ Boolean
- #connection ⇒ Object
- #connection=(adapter) ⇒ Object
- #establish_connection(config = nil) ⇒ Object
- #remove_connection ⇒ Object
- #retrieve_connection ⇒ Object
- #schema ⇒ Object
- #setup_connection(config = nil) ⇒ Object
Instance Method Details
#connected? ⇒ Boolean
243 244 245 |
# File 'lib/active_ldap/connection.rb', line 243 def connected? connection != self.class.connection end |
#connection ⇒ Object
228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
# File 'lib/active_ldap/connection.rb', line 228 def connection conn = @connection return conn if conn have_dn = !@dn.nil? if !have_dn and attribute_name_resolvable_without_connection? begin have_dn = !get_attribute_before_type_cast(dn_attribute)[1].nil? rescue DistinguishedNameInvalid end end conn = self.class.active_connections[dn] || retrieve_connection if have_dn conn || self.class.connection end |
#connection=(adapter) ⇒ Object
247 248 249 250 251 252 253 254 255 256 |
# File 'lib/active_ldap/connection.rb', line 247 def connection=(adapter) if adapter.nil? or adapter.is_a?(Adapter::Base) @connection = adapter elsif adapter.is_a?(Hash) config = adapter @connection = self.class.instantiate_adapter(config) else setup_connection(adapter) end end |
#establish_connection(config = nil) ⇒ Object
214 215 216 217 218 219 220 221 |
# File 'lib/active_ldap/connection.rb', line 214 def establish_connection(config=nil) = _("ActiveLdap::Connection#establish_connection has been deprecated " \ "since 1.1.0. " \ "Please use ActiveLdap::Connection#setup_connection instead.") ActiveSupport::Deprecation.warn() setup_connection(config) end |
#remove_connection ⇒ Object
223 224 225 226 |
# File 'lib/active_ldap/connection.rb', line 223 def remove_connection self.class.remove_connection(dn) @connection = nil end |
#retrieve_connection ⇒ Object
258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/active_ldap/connection.rb', line 258 def retrieve_connection conn = self.class.active_connections[dn] return conn if conn config = self.class.configuration(dn) return nil unless config conn = self.class.instantiate_adapter(config) @connection = self.class.active_connections[dn] = conn conn end |
#schema ⇒ Object
270 271 272 |
# File 'lib/active_ldap/connection.rb', line 270 def schema connection.schema end |
#setup_connection(config = nil) ⇒ Object
205 206 207 208 209 210 211 212 |
# File 'lib/active_ldap/connection.rb', line 205 def setup_connection(config=nil) config = self.class.ensure_configuration(config) config = self.class.configuration.merge(config) config = self.class.merge_configuration(config, self) remove_connection self.class.define_configuration(dn, config) end |