diff options
author | Ed Tanous <ed@tanous.net> | 2024-03-20 22:49:15 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-03-27 22:17:59 +0300 |
commit | 49cc263fdcfc9b279c399c0b03bfd7e9167e06c2 (patch) | |
tree | 62912b6405d04c80f4d07c1fcf6ce1c077ea7319 /redfish-core | |
parent | e5ae9c1c8787f9d8edf6f46acc7cdb83004f5125 (diff) | |
download | bmcweb-49cc263fdcfc9b279c399c0b03bfd7e9167e06c2.tar.xz |
Fix unused variable warning in LDAP
It's not clear how this came to be the way it is, but tidy now warns
that this variable is unused (which it is).
Refactor the LDAP code to not use the variable, and to use concrete
object_t and array_t
Tested: Redfish service validator passes.
Change-Id: I0c106d10594a396d506bf9865cb29d4a10a372a1
Signed-off-by: Ed Tanous <ed@tanous.net>
Diffstat (limited to 'redfish-core')
-rw-r--r-- | redfish-core/lib/account_service.hpp | 47 |
1 files changed, 28 insertions, 19 deletions
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp index ab9048a435..23f1616964 100644 --- a/redfish-core/lib/account_service.hpp +++ b/redfish-core/lib/account_service.hpp @@ -321,27 +321,32 @@ inline void parseLDAPConfigData(nlohmann::json& jsonResponse, const LDAPConfigData& confData, const std::string& ldapType) { - std::string service = (ldapType == "LDAP") ? "LDAPService" - : "ActiveDirectoryService"; - - nlohmann::json& ldap = jsonResponse[ldapType]; - + nlohmann::json::object_t ldap; ldap["ServiceEnabled"] = confData.serviceEnabled; - ldap["ServiceAddresses"] = nlohmann::json::array({confData.uri}); - ldap["Authentication"]["AuthenticationType"] = + nlohmann::json::array_t serviceAddresses; + serviceAddresses.emplace_back(confData.uri); + ldap["ServiceAddresses"] = std::move(serviceAddresses); + + nlohmann::json::object_t authentication; + authentication["AuthenticationType"] = account_service::AuthenticationTypes::UsernameAndPassword; - ldap["Authentication"]["Username"] = confData.bindDN; - ldap["Authentication"]["Password"] = nullptr; - - ldap["LDAPService"]["SearchSettings"]["BaseDistinguishedNames"] = - nlohmann::json::array({confData.baseDN}); - ldap["LDAPService"]["SearchSettings"]["UsernameAttribute"] = - confData.userNameAttribute; - ldap["LDAPService"]["SearchSettings"]["GroupsAttribute"] = - confData.groupAttribute; - - nlohmann::json& roleMapArray = ldap["RemoteRoleMapping"]; - roleMapArray = nlohmann::json::array(); + authentication["Username"] = confData.bindDN; + authentication["Password"] = nullptr; + ldap["Authentication"] = std::move(authentication); + + nlohmann::json::object_t ldapService; + nlohmann::json::object_t searchSettings; + nlohmann::json::array_t baseDistinguishedNames; + baseDistinguishedNames.emplace_back(confData.baseDN); + + searchSettings["BaseDistinguishedNames"] = + std::move(baseDistinguishedNames); + searchSettings["UsernameAttribute"] = confData.userNameAttribute; + searchSettings["GroupsAttribute"] = confData.groupAttribute; + ldapService["SearchSettings"] = std::move(searchSettings); + ldap["LDAPService"] = std::move(ldapService); + + nlohmann::json::array_t roleMapArray; for (const auto& obj : confData.groupRoleList) { BMCWEB_LOG_DEBUG("Pushing the data groupName={}", obj.second.groupName); @@ -351,6 +356,10 @@ inline void parseLDAPConfigData(nlohmann::json& jsonResponse, remoteGroup["LocalRole"] = getRoleIdFromPrivilege(obj.second.privilege); roleMapArray.emplace_back(std::move(remoteGroup)); } + + ldap["RemoteRoleMapping"] = std::move(roleMapArray); + + jsonResponse[ldapType].update(ldap); } /** |