diff options
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); } /** |