627: def search args = {}
628: args[:base] ||= @base
629: result_set = (args and args[:return_result] == false) ? nil : []
630:
631: if @open_connection
632: @result = @open_connection.search( args ) {|entry|
633: result_set << entry if result_set
634: yield( entry ) if block_given?
635: }
636: else
637: @result = 0
638: conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
639: if (@result = conn.bind( args[:auth] || @auth )) == 0
640: @result = conn.search( args ) {|entry|
641: result_set << entry if result_set
642: yield( entry ) if block_given?
643: }
644: end
645: conn.close
646: end
647:
648: @result == 0 and result_set
649: end