Class: ActiveLdap::Configuration::ClassMethods::URIConfigurationMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/active_ldap/configuration.rb

Instance Method Summary collapse

Constructor Details

#initialize(uri) ⇒ URIConfigurationMerger

Returns a new instance of URIConfigurationMerger



146
147
148
# File 'lib/active_ldap/configuration.rb', line 146

def initialize(uri)
  @uri = uri
end

Instance Method Details

#merge(configuration) ⇒ Object



150
151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/active_ldap/configuration.rb', line 150

def merge(configuration)
  uri_configuration = {:port => @uri.port}
  uri_configuration[:host] = @uri.host if @uri.host
  uri_configuration[:base] = @uri.dn if @uri.dn
  extensions = parse_extensions
  bindname_extension = extensions["bindname"]
  if bindname_extension
    uri_configuration[:bind_dn] = bindname_extension[:value]
    uri_configuration[:allow_anonymous] = !bindname_extension[:critical]
  end
  uri_configuration[:scope] = @uri.scope if @uri.scope
  uri_configuration[:method] = :ssl if @uri.is_a?(URI::LDAPS)
  uri_configuration.merge(configuration)
end