Module | ActiveLdap::Operations::Update |
In: |
lib/active_ldap/operations.rb
|
# File lib/active_ldap/operations.rb, line 477 477: def add_entry(dn, attributes, options={}) 478: unnormalized_attributes = attributes.collect do |key, value| 479: [:add, key, unnormalize_attribute(key, value)] 480: end 481: options[:connection] ||= connection 482: options[:connection].add(dn, unnormalized_attributes, options) 483: end
# File lib/active_ldap/operations.rb, line 485 485: def modify_entry(dn, attributes, options={}) 486: return if attributes.empty? 487: unnormalized_attributes = attributes.collect do |type, key, value| 488: [type, key, unnormalize_attribute(key, value)] 489: end 490: options[:connection] ||= connection 491: options[:connection].modify(dn, unnormalized_attributes, options) 492: end
# File lib/active_ldap/operations.rb, line 494 494: def modify_rdn_entry(dn, new_rdn, delete_old_rdn, new_superior, options={}) 495: options[:connection] ||= connection 496: options[:connection].modify_rdn(dn, new_rdn, delete_old_rdn, 497: new_superior, options) 498: end
# File lib/active_ldap/operations.rb, line 500 500: def update(dn, attributes, options={}) 501: if dn.is_a?(Array) 502: i = -1 503: dns = dn 504: dns.collect do |dn| 505: i += 1 506: update(dn, attributes[i], options) 507: end 508: else 509: object = find(dn, options) 510: object.update_attributes(attributes) 511: object 512: end 513: end
# File lib/active_ldap/operations.rb, line 515 515: def update_all(attributes, filter=nil, options={}) 516: search_options = options.dup 517: if filter 518: if filter.is_a?(String) and /[=\(\)&\|]/ !~ filter 519: search_options = search_options.merge(:value => filter) 520: else 521: search_options = search_options.merge(:filter => filter) 522: end 523: end 524: targets = search(search_options).collect do |dn, attrs| 525: dn 526: end 527: 528: unnormalized_attributes = attributes.collect do |name, value| 529: normalized_name, normalized_value = normalize_attribute(name, value) 530: [:replace, normalized_name, 531: unnormalize_attribute(normalized_name, normalized_value)] 532: end 533: options[:connection] ||= connection 534: conn = options[:connection] 535: targets.each do |dn| 536: conn.modify(dn, unnormalized_attributes, options) 537: end 538: end