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