Make LDAP arrays empty if not configured
These arrays should not be populated if there are no handlers for these
configured.
Fixes https://github.com/openbmc/bmcweb/issues/105
Change-Id: Idbd04eb97ced75e44de6ed98aa1f0d410f0aebc7
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/lib/account_service.hpp b/redfish-core/lib/account_service.hpp
index e530d3e..173d966 100644
--- a/redfish-core/lib/account_service.hpp
+++ b/redfish-core/lib/account_service.hpp
@@ -331,7 +331,10 @@
nlohmann::json::object_t ldap;
ldap["ServiceEnabled"] = confData.serviceEnabled;
nlohmann::json::array_t serviceAddresses;
- serviceAddresses.emplace_back(confData.uri);
+ if (!confData.uri.empty())
+ {
+ serviceAddresses.emplace_back(confData.uri);
+ }
ldap["ServiceAddresses"] = std::move(serviceAddresses);
nlohmann::json::object_t authentication;
@@ -344,7 +347,10 @@
nlohmann::json::object_t ldapService;
nlohmann::json::object_t searchSettings;
nlohmann::json::array_t baseDistinguishedNames;
- baseDistinguishedNames.emplace_back(confData.baseDN);
+ if (!confData.baseDN.empty())
+ {
+ baseDistinguishedNames.emplace_back(confData.baseDN);
+ }
searchSettings["BaseDistinguishedNames"] =
std::move(baseDistinguishedNames);