xref: /openbmc/sdbusplus/example/list-users.cpp (revision e1c73d3b)
1 #include <sdbusplus/bus.hpp>
2 
3 #include <cstdint>
4 #include <iostream>
5 
6 /** An example dbus client application.
7  *  Calls org.freedesktop.login1's ListUsers interface to find all active
8  *  users in the system and displays their username.
9  */
10 
11 int main()
12 {
13     using namespace sdbusplus;
14 
15     auto b = bus::new_default_system();
16     auto m =
17         b.new_method_call("org.freedesktop.login1", "/org/freedesktop/login1",
18                           "org.freedesktop.login1.Manager", "ListUsers");
19     auto reply = b.call(m);
20 
21     std::vector<std::tuple<uint32_t, std::string, message::object_path>> users;
22     reply.read(users);
23 
24     for (auto& user : users)
25     {
26         std::cout << std::get<std::string>(user) << "\n";
27     }
28 
29     return 0;
30 }
31