Method: LDAP#set_entry
- Defined in:
- lib/qooxview/storages/ldap.rb
#set_entry(id, field, value) ⇒ Object
Searches for the field in the LDAP-entry, changes it and returns the new value (which might not be what you expected).
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/qooxview/storages/ldap.rb', line 148 def set_entry(id, field, value) dputs(3) { "Fields is #{@fields.inspect}" } attribute = @fields[field.to_sym][:ldap_name] if not attribute return value end dn = @dns[id.to_i] value_stored = value.class == Array ? value.to_json : value dputs(3) { 'Replacing attribute in ' + "#{[@data_ldap_pass, dn, attribute, field, value, value_stored].inspect}" } 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 nil end ret = @data_ldap.replace_attribute(dn, attribute, value_stored.to_s) dputs(3) { "Replaced #{attribute} in #{dn} with #{value}" } unless ret dputs(0) { "State of LDAP is: #{@data_ldap.get_operation_result.}" } 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) if value_stored.to_s == value_entry dputs(4) { "returning value #{value.inspect}" } return value else dputs(0) { "Error: Didn't get right return value: #{value_entry.inspect} instead of #{value_stored.inspect}" } end end return nil end |