def search args = {}
unless args[:ignore_server_caps]
args[:paged_searches_supported] = paged_searches_supported?
end
args[:base] ||= @base
result_set = (args and args[:return_result] == false) ? nil : []
if @open_connection
@result = @open_connection.search( args ) {|entry|
result_set << entry if result_set
yield( entry ) if block_given?
}
else
@result = 0
begin
conn = Connection.new( :host => @host, :port => @port, :encryption => @encryption )
if (@result = conn.bind( args[:auth] || @auth )) == 0
@result = conn.search( args ) {|entry|
result_set << entry if result_set
yield( entry ) if block_given?
}
end
ensure
conn.close if conn
end
end
@result == 0 and result_set
end