# File lib/puppet/util/ldap/manager.rb, line 217
217:     def update(name, is, should)
218:         if should[:ensure] == :absent
219:             Puppet.info "Removing %s from ldap" % dn(name)
220:             delete(name)
221:             return
222:         end
223: 
224:         # We're creating a new entry
225:         if is.empty? or is[:ensure] == :absent
226:             Puppet.info "Creating %s in ldap" % dn(name)
227:             # Remove any :absent params and :ensure, then convert the names to ldap names.
228:             attrs = ldap_convert(should)
229:             create(name, attrs)
230:             return
231:         end
232: 
233:         # We're modifying an existing entry.  Yuck.
234: 
235:         mods = []
236:         # For each attribute we're deleting that is present, create a
237:         # modify instance for deletion.
238:         [is.keys, should.keys].flatten.uniq.each do |property|
239:             # They're equal, so do nothing.
240:             next if is[property] == should[property]
241: 
242:             attributes = ldap_convert(should)
243: 
244:             prop_name = ldap_name(property).to_s
245: 
246:             # We're creating it.
247:             if is[property] == :absent or is[property].nil?
248:                 mods << LDAP::Mod.new(LDAP::LDAP_MOD_ADD, prop_name, attributes[prop_name])
249:                 next
250:             end
251: 
252:             # We're deleting it
253:             if should[property] == :absent or should[property].nil?
254:                 mods << LDAP::Mod.new(LDAP::LDAP_MOD_DELETE, prop_name, [])
255:                 next
256:             end
257: 
258:             # We're replacing an existing value
259:             mods << LDAP::Mod.new(LDAP::LDAP_MOD_REPLACE, prop_name, attributes[prop_name])
260:         end
261: 
262:         modify(name, mods)
263:     end