| Module | ActiveLdap::Operations::Update |
| In: |
lib/active_ldap/operations.rb
|
# File lib/active_ldap/operations.rb, line 545
545: def add_entry(dn, attributes, options={})
546: unnormalized_attributes = attributes.collect do |key, value|
547: [:add, key, unnormalize_attribute(key, value)]
548: end
549: options[:connection] ||= connection
550: options[:connection].add(dn, unnormalized_attributes, options)
551: end
# File lib/active_ldap/operations.rb, line 553
553: def modify_entry(dn, attributes, options={})
554: return if attributes.empty?
555: unnormalized_attributes = attributes.collect do |type, key, value|
556: [type, key, unnormalize_attribute(key, value)]
557: end
558: options[:connection] ||= connection
559: options[:connection].modify(dn, unnormalized_attributes, options)
560: end
# File lib/active_ldap/operations.rb, line 562
562: def modify_rdn_entry(dn, new_rdn, delete_old_rdn, new_superior, options={})
563: options[:connection] ||= connection
564: options[:connection].modify_rdn(dn, new_rdn, delete_old_rdn,
565: new_superior, options)
566: end
# File lib/active_ldap/operations.rb, line 568
568: def update(dn, attributes, options={})
569: if dn.is_a?(Array)
570: i = -1
571: dns = dn
572: dns.collect do |_dn|
573: i += 1
574: update(_dn, attributes[i], options)
575: end
576: else
577: object = find(dn, options)
578: object.update_attributes(attributes)
579: object
580: end
581: end
# File lib/active_ldap/operations.rb, line 583
583: def update_all(attributes, filter=nil, options={})
584: search_options = options.dup
585: if filter
586: if filter.is_a?(String) and /[=\(\)&\|]/ !~ filter
587: search_options = search_options.merge(:value => filter)
588: else
589: search_options = search_options.merge(:filter => filter)
590: end
591: end
592: targets = search(search_options).collect do |dn, attrs|
593: dn
594: end
595:
596: unnormalized_attributes = attributes.collect do |name, value|
597: normalized_name, normalized_value = normalize_attribute(name, value)
598: [:replace, normalized_name,
599: unnormalize_attribute(normalized_name, normalized_value)]
600: end
601: options[:connection] ||= connection
602: conn = options[:connection]
603: targets.each do |dn|
604: conn.modify(dn, unnormalized_attributes, options)
605: end
606: end