| Module | ActiveLdap::Operations::Update |
| In: |
lib/active_ldap/operations.rb
|
# File lib/active_ldap/operations.rb, line 516
516: def add_entry(dn, attributes, options={})
517: unnormalized_attributes = attributes.collect do |key, value|
518: [:add, key, unnormalize_attribute(key, value)]
519: end
520: options[:connection] ||= connection
521: options[:connection].add(dn, unnormalized_attributes, options)
522: end
# File lib/active_ldap/operations.rb, line 524
524: def modify_entry(dn, attributes, options={})
525: return if attributes.empty?
526: unnormalized_attributes = attributes.collect do |type, key, value|
527: [type, key, unnormalize_attribute(key, value)]
528: end
529: options[:connection] ||= connection
530: options[:connection].modify(dn, unnormalized_attributes, options)
531: end
# File lib/active_ldap/operations.rb, line 533
533: def modify_rdn_entry(dn, new_rdn, delete_old_rdn, new_superior, options={})
534: options[:connection] ||= connection
535: options[:connection].modify_rdn(dn, new_rdn, delete_old_rdn,
536: new_superior, options)
537: end
# File lib/active_ldap/operations.rb, line 539
539: def update(dn, attributes, options={})
540: if dn.is_a?(Array)
541: i = -1
542: dns = dn
543: dns.collect do |_dn|
544: i += 1
545: update(_dn, attributes[i], options)
546: end
547: else
548: object = find(dn, options)
549: object.update_attributes(attributes)
550: object
551: end
552: end
# File lib/active_ldap/operations.rb, line 554
554: def update_all(attributes, filter=nil, options={})
555: search_options = options.dup
556: if filter
557: if filter.is_a?(String) and /[=\(\)&\|]/ !~ filter
558: search_options = search_options.merge(:value => filter)
559: else
560: search_options = search_options.merge(:filter => filter)
561: end
562: end
563: targets = search(search_options).collect do |dn, attrs|
564: dn
565: end
566:
567: unnormalized_attributes = attributes.collect do |name, value|
568: normalized_name, normalized_value = normalize_attribute(name, value)
569: [:replace, normalized_name,
570: unnormalize_attribute(normalized_name, normalized_value)]
571: end
572: options[:connection] ||= connection
573: conn = options[:connection]
574: targets.each do |dn|
575: conn.modify(dn, unnormalized_attributes, options)
576: end
577: end