phosphor-ldap-conf: add application to configure LDAP

The application implements the xyz.openbmc_project.User.Ldap.Config
and xyz.openbmc_project.User.Ldap.Create D-Bus interfaces to create
LDAP config file(for example generate nslcd.conf)

Change-Id: Idc7cc643c4143f9bc51182019926e1dd6125da2f
Signed-off-by: Nagaraju Goruganti <ngorugan@in.ibm.com>
diff --git a/phosphor-ldap-config/main.cpp b/phosphor-ldap-config/main.cpp
new file mode 100644
index 0000000..6bba619
--- /dev/null
+++ b/phosphor-ldap-config/main.cpp
@@ -0,0 +1,40 @@
+#include "config.h"
+#include "ldap_configuration.hpp"
+#include <experimental/filesystem>
+#include <phosphor-logging/log.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <sdbusplus/bus.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
+int main(int argc, char* argv[])
+{
+    using namespace phosphor::logging;
+    using namespace sdbusplus::xyz::openbmc_project::Common::Error;
+    namespace fs = std::experimental::filesystem;
+
+    if (!fs::exists(phosphor::ldap::defaultNslcdFile) ||
+        !fs::exists(phosphor::ldap::nsSwitchFile) ||
+        (!fs::exists(phosphor::ldap::LDAPNsSwitchFile) &&
+         !fs::exists(phosphor::ldap::linuxNsSwitchFile)))
+    {
+        log<level::ERR>("Error starting LDAP Config App, configfile(s) are "
+                        "missing, exiting!!!");
+        elog<InternalFailure>();
+    }
+    auto bus = sdbusplus::bus::new_default();
+
+    // Add sdbusplus ObjectManager for the 'root' path of the LDAP config.
+    sdbusplus::server::manager::manager objManager(bus, LDAP_CONFIG_ROOT);
+
+    phosphor::ldap::ConfigMgr mgr(bus, LDAP_CONFIG_ROOT);
+
+    bus.request_name(LDAP_CONFIG_BUSNAME);
+
+    while (true)
+    {
+        bus.process_discard();
+        bus.wait();
+    }
+
+    return 0;
+}