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