lib/qooxview/storages/ldap.rb in qooxview-1.9.10 vs lib/qooxview/storages/ldap.rb in qooxview-1.9.11

- old
+ new

@@ -16,10 +16,15 @@ end dputs(3) { "Returning #{file} for #{first}-#{second}-#{config}" } file end + + def get_param(lc, param) + lc['__anonymous__'][param].delete('"\'') + end + # Load the configuration file and set up different variables # for LDAP. This has to be loaded just once def configure(config) #dputs_func dputs(2) { "Configuring LDAP: #{config.inspect}" } @@ -28,14 +33,14 @@ @data_ldap_pass = conf else file_conf = LDAP.get_config_file('ldapscripts.conf', '/etc/ldapscripts/ldapscripts.conf', :ldapscripts) ldap_config = IniParse.parse(File.read(file_conf)) - dputs(2) { "Configuration options are #{ldap_config.get_params.inspect}" } + dputs(3) { "Configuration options are #{ldap_config.to_hash.inspect}" } @data_ldap_host, @data_ldap_base, @data_ldap_root, @data_ldap_users = - ldap_config['SERVER'], ldap_config['SUFFIX'], ldap_config['BINDDN'], - ldap_config['USUFFIX'] + get_param(ldap_config, 'SERVER'), get_param(ldap_config, 'SUFFIX'), + get_param(ldap_config, 'BINDDN'), get_param(ldap_config, 'USUFFIX') file_pass = LDAP.get_config_file('ldap.secret', '/etc/ldap.secret', :ldapsecret) @data_ldap_pass = `cat #{ file_pass }` end @@ -150,18 +155,21 @@ value_stored = value.class == Array ? value.to_json : value dputs(3) { 'Replacing attribute in ' + "#{[@data_ldap_pass, dn, attribute, field, value, value_stored].inspect}" } - if not dn + unless dn dputs(0) { "Error: DN is empty... #{@dns.to_a.last(10).inspect}" } dputs(0) { "Error: DN is empty: id, field, value = #{id}, #{field}, #{value}" } - #return + return nil end ret = @data_ldap.replace_attribute(dn, attribute, value_stored.to_s) dputs(3) { "Replaced #{attribute} in #{dn} with #{value}" } - dputs(3) { "State of LDAP is: #{@data_ldap.get_operation_result.message} - #{ret.inspect}" } + unless ret + dputs(0) { "State of LDAP is: #{@data_ldap.get_operation_result.message}" } + return nil + end @data_ldap.search(:base => @data_ldap_base, :filter => Net::LDAP::Filter.eq(@field_id_ldap.to_s, id.to_s)) do |entry| dputs(3) { "Found entry: #{entry.inspect}" } value_entry = entry[attribute][0].to_s value_entry.force_encoding(Encoding::UTF_8)