Create the default object for openldap and AD.

This commit introduces the following functionalities
=> Default AD and openldap config object would always be there.
=> User should not be able to change the type of the ldap
   once it is created.

This change is to align with redfish sehema
(https://redfish.dmtf.org/schemas/AccountService.v1_4_0.json),
In the schema AD and LDAP is a property which user can PATCH,
Now with the current code which doesn't have the default config
so for the PATCH, We were forcing the user to give all the
properties and then create the object which is against the
PATCH semantics.

TestedBy: Unit tested
          Default Object gets created when service starts.
          change of ldap type gets the error back.

Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Change-Id: I0ce951a13ee525df022fb0716f0aea10d1909781
diff --git a/phosphor-ldap-config/ldap_config_mgr.hpp b/phosphor-ldap-config/ldap_config_mgr.hpp
index b30d98c..a3895ae 100644
--- a/phosphor-ldap-config/ldap_config_mgr.hpp
+++ b/phosphor-ldap-config/ldap_config_mgr.hpp
@@ -18,6 +18,10 @@
 
 static constexpr auto defaultNslcdFile = "nslcd.conf.default";
 static constexpr auto nsSwitchFile = "nsswitch.conf";
+static auto openLDAPDbusObjectPath =
+    std::string(LDAP_CONFIG_ROOT) + "/openldap";
+static auto ADDbusObjectPath =
+    std::string(LDAP_CONFIG_ROOT) + "/active_directory";
 
 using namespace phosphor::logging;
 using namespace sdbusplus::xyz::openbmc_project::Common::Error;
@@ -53,17 +57,6 @@
         dbusPersistentPath(dbusPersistentPath), configFilePath(filePath),
         bus(bus)
     {
-        try
-        {
-            restore(configFilePath.c_str());
-            emit_object_added();
-        }
-        catch (const std::exception& e)
-        {
-            configPtr.reset(nullptr);
-            log<level::ERR>(e.what());
-            elog<InternalFailure>();
-        }
     }
 
     /** @brief concrete implementation of the pure virtual funtion
@@ -110,6 +103,10 @@
      */
     void deleteObject();
 
+    /* Create the default active directory and the openldap config
+     * objects. */
+    virtual void createDefaultObjects();
+
     /* ldap service enabled property would be saved under
      * this path.
      */
@@ -122,13 +119,17 @@
     /** @brief Persistent sdbusplus D-Bus bus connection. */
     sdbusplus::bus::bus& bus;
 
-    /** @brief Pointer to a Config D-Bus object */
-    std::unique_ptr<Config> configPtr = nullptr;
+    /* Below two config objects are default, which will always be there */
 
-    /** @brief Populate existing config into D-Bus properties
-     *  @param[in] filePath - LDAP config file path
-     */
-    virtual void restore(const char* filePath);
+    /* if need arises then we can have below map for additional account
+     * providers we need to create sub class of Config which will implement the
+     * delete interface as the default objects will not implement the delete
+     * std::map<std::string, std::unique_ptr<NewConfig>> AdditionalProviders*/
+
+    /** @brief Pointer to a openLDAP Config D-Bus object */
+    std::unique_ptr<Config> openLDAPConfigPtr = nullptr;
+    /** @brief Pointer to a AD Config D-Bus object */
+    std::unique_ptr<Config> ADConfigPtr = nullptr;
 };
 } // namespace ldap
 } // namespace phosphor