Module: ActiveLdap::Operations::Delete
- Defined in:
- lib/active_ldap/operations.rb
Instance Method Summary collapse
- #delete(targets, options = {}) ⇒ Object
- #delete_all(options_or_filter = nil, deprecated_options = nil) ⇒ Object
- #delete_entry(dn, options = {}) ⇒ Object
- #destroy(targets, options = {}) ⇒ Object
- #destroy_all(options_or_filter = nil, deprecated_options = nil) ⇒ Object
Instance Method Details
#delete(targets, options = {}) ⇒ Object
507 508 509 510 511 512 513 |
# File 'lib/active_ldap/operations.rb', line 507 def delete(targets, ={}) targets = [targets] unless targets.is_a?(Array) targets = targets.collect do |target| ensure_dn_attribute(ensure_base(target)) end delete_entry(targets, ) end |
#delete_all(options_or_filter = nil, deprecated_options = nil) ⇒ Object
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 |
# File 'lib/active_ldap/operations.rb', line 525 def delete_all(=nil, =nil) if .nil? if .is_a?(String) = {:filter => } else = ( || {}).dup end else = .merge(:filter => ) end targets = search().collect do |dn, attributes| dn end.sort_by do |dn| dn.upcase.reverse end.reverse delete_entry(targets, ) end |
#delete_entry(dn, options = {}) ⇒ Object
515 516 517 518 519 520 521 522 523 |
# File 'lib/active_ldap/operations.rb', line 515 def delete_entry(dn, ={}) [:connection] ||= connection begin [:connection].delete(dn, ) rescue Error format = _("Failed to delete LDAP entry: <%s>: %s") raise DeleteError.new(format % [dn.inspect, $!.]) end end |
#destroy(targets, options = {}) ⇒ Object
482 483 484 485 486 487 |
# File 'lib/active_ldap/operations.rb', line 482 def destroy(targets, ={}) targets = [targets] unless targets.is_a?(Array) targets.each do |target| find(target, ).destroy end end |
#destroy_all(options_or_filter = nil, deprecated_options = nil) ⇒ Object
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
# File 'lib/active_ldap/operations.rb', line 489 def destroy_all(=nil, =nil) if .nil? if .is_a?(String) = {:filter => } else = ( || {}).dup end else = .merge(:filter => ) end find(:all, ).sort_by do |target| target.dn end.each do |target| target.destroy end end |