| Module | ActiveLdap::Operations::Update |
| In: |
lib/active_ldap/operations.rb
|
# File lib/active_ldap/operations.rb, line 372
372: def add_entry(dn, attributes, options={})
373: unnormalized_attributes = attributes.collect do |type, key, value|
374: [type, key, unnormalize_attribute(key, value)]
375: end
376: options[:connection] ||= connection
377: options[:connection].add(dn, unnormalized_attributes, options)
378: end
# File lib/active_ldap/operations.rb, line 380
380: def modify_entry(dn, attributes, options={})
381: unnormalized_attributes = attributes.collect do |type, key, value|
382: [type, key, unnormalize_attribute(key, value)]
383: end
384: options[:connection] ||= connection
385: options[:connection].modify(dn, unnormalized_attributes, options)
386: end
# File lib/active_ldap/operations.rb, line 388
388: def update(dn, attributes, options={})
389: if dn.is_a?(Array)
390: i = -1
391: dns = dn
392: dns.collect do |dn|
393: i += 1
394: update(dn, attributes[i], options)
395: end
396: else
397: object = find(dn, options)
398: object.update_attributes(attributes)
399: object
400: end
401: end
# File lib/active_ldap/operations.rb, line 403
403: def update_all(attributes, filter=nil, options={})
404: search_options = options.dup
405: if filter
406: if filter.is_a?(String) and /[=\(\)&\|]/ !~ filter
407: search_options = search_options.merge(:value => filter)
408: else
409: search_options = search_options.merge(:filter => filter)
410: end
411: end
412: targets = search(search_options).collect do |dn, attrs|
413: dn
414: end
415:
416: unnormalized_attributes = attributes.collect do |name, value|
417: normalized_name, normalized_value = normalize_attribute(name, value)
418: [:replace, normalized_name,
419: unnormalize_attribute(normalized_name, normalized_value)]
420: end
421: options[:connection] ||= connection
422: conn = options[:connection]
423: targets.each do |dn|
424: conn.modify(dn, unnormalized_attributes, options)
425: end
426: end