class LDAP::Conn

def paged_search(base, scope, filter, attributes, limit, page_size, &block)

def paged_search(base, scope, filter, attributes, limit, page_size, &block)
  cookie = ""
  critical = true
  loop do
    ber_string = LDAP::Control.encode(page_size, cookie)
    control = LDAP::Control.new(LDAP::LDAP_CONTROL_PAGEDRESULTS,
                                ber_string,
                                critical)
    search_ext(base,
               scope,
               filter,
               attributes,
               false,
               [control],
               nil,
               0,
               0,
               limit,
               &block)
    control = find_paged_results_control(@controls)
    break if control.nil?
    _estimated_result_set_size, cookie = control.decode
    break if cookie.empty?
  end
end