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