# module ActiveLdap::Operations::Delete

### Public Instance Methods

delete_all(options_or_filter=nil, deprecated_options=nil) click to toggle source

    # File lib/active_ldap/operations.rb, line 510
    def delete_all(options_or_filter=nil, deprecated_options=nil)
      if deprecated_options.nil?
        if options_or_filter.is_a?(String)
          options = {:filter => options_or_filter}
        else
          options = (options_or_filter || {}).dup
        end
      else
        options = deprecated_options.merge(:filter => options_or_filter)
      end
      targets = search(options).collect do |dn, attributes|
        dn
      end.sort_by do |dn|
        dn.upcase.reverse
      end.reverse

      delete_entry(targets, options)
    end

delete_entry(dn, options={}) click to toggle source

    # File lib/active_ldap/operations.rb, line 529
    def delete_entry(dn, options={})
      options[:connection] ||= connection
      begin
        options[:connection].delete(dn, options)
      rescue Error
        format = _("Failed to delete LDAP entry: <%s>: %s")
        raise DeleteError.new(format % [dn.inspect, $!.message])
      end
    end

destroy_all(options_or_filter=nil, deprecated_options=nil) click to toggle source

    # File lib/active_ldap/operations.rb, line 492
    def destroy_all(options_or_filter=nil, deprecated_options=nil)
      if deprecated_options.nil?
        if options_or_filter.is_a?(String)
          options = {:filter => options_or_filter}
        else
          options = (options_or_filter || {}).dup
        end
      else
        options = deprecated_options.merge(:filter => options_or_filter)
      end

      find(:all, options).sort_by do |target|
        target.dn
      end.each do |target|
        target.destroy
      end
    end