Using sdbusplus::asio::getProperty

It simplifies a lot of code and after changing sdbusplus implementation
slightly reduces binary size if used together with:

https://gerrit.openbmc-project.xyz/c/openbmc/sdbusplus/+/49467

* Uncompressed size:    3033148 -> 3012164, -20984 B
* gzip compressed size: 1220586 -> 1214625, -5961 B

Tested:
- Redfish validator output is the same before and after the change

Change-Id: Ibe3227d3f4230de2363ba3d9396e51130c8240a5
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
diff --git a/redfish-core/lib/roles.hpp b/redfish-core/lib/roles.hpp
index 5aa1a22..c18942f 100644
--- a/redfish-core/lib/roles.hpp
+++ b/redfish-core/lib/roles.hpp
@@ -18,9 +18,9 @@
 #include <app.hpp>
 #include <dbus_utility.hpp>
 #include <registries/privilege_registry.hpp>
+#include <sdbusplus/asio/property.hpp>
 
 #include <variant>
-
 namespace redfish
 {
 
@@ -114,9 +114,13 @@
                     {"Name", "Roles Collection"},
                     {"Description", "BMC User Roles"}};
 
-                crow::connections::systemBus->async_method_call(
+                sdbusplus::asio::getProperty<std::vector<std::string>>(
+                    *crow::connections::systemBus,
+                    "xyz.openbmc_project.User.Manager",
+                    "/xyz/openbmc_project/user",
+                    "xyz.openbmc_project.User.Manager", "AllPrivileges",
                     [asyncResp](const boost::system::error_code ec,
-                                const dbus::utility::DbusVariantType& resp) {
+                                const std::vector<std::string>& privList) {
                         if (ec)
                         {
                             messages::internalError(asyncResp->res);
@@ -125,14 +129,7 @@
                         nlohmann::json& memberArray =
                             asyncResp->res.jsonValue["Members"];
                         memberArray = nlohmann::json::array();
-                        const std::vector<std::string>* privList =
-                            std::get_if<std::vector<std::string>>(&resp);
-                        if (privList == nullptr)
-                        {
-                            messages::internalError(asyncResp->res);
-                            return;
-                        }
-                        for (const std::string& priv : *privList)
+                        for (const std::string& priv : privList)
                         {
                             std::string role = getRoleFromPrivileges(priv);
                             if (!role.empty())
@@ -145,11 +142,7 @@
                         }
                         asyncResp->res.jsonValue["Members@odata.count"] =
                             memberArray.size();
-                    },
-                    "xyz.openbmc_project.User.Manager",
-                    "/xyz/openbmc_project/user",
-                    "org.freedesktop.DBus.Properties", "Get",
-                    "xyz.openbmc_project.User.Manager", "AllPrivileges");
+                    });
             });
 }