summaryrefslogtreecommitdiffstats
path: root/phosphor-ldap-config/ldap_configuration.hpp
diff options
context:
space:
mode:
authorRatan Gupta <ratagupt@linux.vnet.ibm.com>2019-02-11 04:41:52 -0600
committerRatan Gupta <ratagupt@linux.vnet.ibm.com>2019-03-11 12:00:02 +0530
commitaeaf9413a965d225d11ee1cd2c8ee9aa1f8dc862 (patch)
treee6abaeaad9709a40b725aafa227306b87645630d /phosphor-ldap-config/ldap_configuration.hpp
parenta929752bef26e02ccd103a5669a402ba2b5d5eec (diff)
downloadphosphor-user-manager-aeaf9413a965d225d11ee1cd2c8ee9aa1f8dc862.tar.gz
phosphor-user-manager-aeaf9413a965d225d11ee1cd2c8ee9aa1f8dc862.zip
squash the following commits
LDAP: Adding support for extra properties Implement GetUserInfo function in phosphor-user-manager Squashing the commits due to phosphor-dbus-interfaces dependency as the interface gets merged and it requires implementation so it is a deadlock for both the commits. Implement GetUserInfo function in phosphor-user-manager There was need to have api which return privilege for ldap user. it was discussed in this commit https://gerrit.openbmc-project.xyz/#/c/openbmc/phosphor-dbus-interfaces/+/12027/ and decided to have generic api. -Checks if user is local user, then returns map of properties of local user like user privilege,list of user groups,user enabled state and user locked state. -If its not local user, then it checks if its a ldap user, then get the privilege mapping for the LDAP group and returns. TestedBy: 1) getUserInfo with local user verify user details. 2) getUserInfo with ldap user having privilege mapper entry, verify user details. 3) getUserInfo with no existing user. check for exception UserNameDoesNotExist. Change-Id: I44af41953db60ff96b39498d72839c2ab64bc8bd Signed-off-by: raviteja-b <raviteja28031990@gmail.com> LDAP: Adding support for extra properties This commit also decouple the ldap service(nslcd) start with each property update,Now there is a D-bus property ldap service enabled which controls that whether the LDAP service will be restarted after each property update,so now user have an option to disable the ldap service and do multi- property update and then enable the service again. TestedBy: 1) Create the config with new added properties Verify that it was getting reflected on the D-bus object. 2) After making the change restarted the ldap-conf service Verify that new properties(usernameattr,groupnameattr) are correctly updated. 3) Authenticaton test Verify that LDAP authentication worked fine. 4) Set the enabled property to true Verify that it starts the nslcd service 5) Set the enabled property to false Verify that it stops the nslcd.service 6) Set the enabled property to true and change any other config property Verify that it starts the nslcd.service 7) Set the enabled property to false which stops the nslcd service and change any other config property. Verify that it doesn't start the nslcd service. Change-Id: Ie3ca04a2adbbb1fe113764199348c4f7ac67f648 Signed-off-by: Ratan Gupta <ratagupt@linux.vnet.ibm.com>
Diffstat (limited to 'phosphor-ldap-config/ldap_configuration.hpp')
-rw-r--r--phosphor-ldap-config/ldap_configuration.hpp71
1 files changed, 58 insertions, 13 deletions
diff --git a/phosphor-ldap-config/ldap_configuration.hpp b/phosphor-ldap-config/ldap_configuration.hpp
index ad2c52a..0d69f08 100644
--- a/phosphor-ldap-config/ldap_configuration.hpp
+++ b/phosphor-ldap-config/ldap_configuration.hpp
@@ -2,6 +2,7 @@
#include "config.h"
#include <xyz/openbmc_project/Object/Delete/server.hpp>
+#include <xyz/openbmc_project/Object/Enable/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Config/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Create/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
@@ -21,10 +22,13 @@ static constexpr auto nsSwitchFile = "nsswitch.conf";
using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
-namespace ldap_base = sdbusplus::xyz::openbmc_project::User::Ldap::server;
-using ConfigIface = sdbusplus::server::object::object<
- ldap_base::Config, sdbusplus::xyz::openbmc_project::Object::server::Delete>;
-using CreateIface = sdbusplus::server::object::object<ldap_base::Create>;
+using ConfigIface = sdbusplus::xyz::openbmc_project::User::Ldap::server::Config;
+using EnableIface = sdbusplus::xyz::openbmc_project::Object::server::Enable;
+using DeleteIface = sdbusplus::xyz::openbmc_project::Object::server::Delete;
+using Ifaces =
+ sdbusplus::server::object::object<ConfigIface, EnableIface, DeleteIface>;
+using CreateIface = sdbusplus::server::object::object<
+ sdbusplus::xyz::openbmc_project::User::Ldap::server::Create>;
class ConfigMgr;
@@ -33,7 +37,7 @@ class ConfigMgr;
* @details concrete implementation of xyz.openbmc_project.User.Ldap.Config
* API, in order to provide LDAP configuration.
*/
-class Config : public ConfigIface
+class Config : public Ifaces
{
public:
Config() = delete;
@@ -55,7 +59,14 @@ class Config : public ConfigIface
* @param[in] lDAPBindDNPassword - credentials with which to bind.
* @param[in] lDAPSearchScope - the search scope.
* @param[in] lDAPType - Specifies the LDAP server type which can be AD
- or openLDAP.
+ * or openLDAP.
+ * @param[in] lDAPServiceEnabled - Specifies whether the service would be
+ * enabled or not.
+ * @param[in] groupNameAttribute - Specifies attribute name that contains
+ * the name of the Group in the LDAP server.
+ * @param[in] userNameAttribute - Specifies attribute name that contains
+ * the username in the LDAP server.
+ *
* @param[in] parent - parent of config object.
*/
@@ -63,15 +74,19 @@ class Config : public ConfigIface
const char* caCertFile, bool secureLDAP, std::string lDAPServerURI,
std::string lDAPBindDN, std::string lDAPBaseDN,
std::string&& lDAPBindDNPassword,
- ldap_base::Config::SearchScope lDAPSearchScope,
- ldap_base::Config::Type lDAPType, ConfigMgr& parent);
+ ConfigIface::SearchScope lDAPSearchScope, ConfigIface::Type lDAPType,
+ bool lDAPServiceEnabled, std::string groupNameAttribute,
+ std::string userNameAttribute, ConfigMgr& parent);
+ using ConfigIface::groupNameAttribute;
using ConfigIface::lDAPBaseDN;
using ConfigIface::lDAPBindDN;
using ConfigIface::lDAPSearchScope;
using ConfigIface::lDAPServerURI;
using ConfigIface::lDAPType;
using ConfigIface::setPropertyByName;
+ using ConfigIface::userNameAttribute;
+ using EnableIface::enabled;
/** @brief Update the Server URI property.
* @param[in] value - lDAPServerURI value to be updated.
@@ -95,14 +110,32 @@ class Config : public ConfigIface
* @param[in] value - lDAPSearchScope value to be updated.
* @returns value of changed lDAPSearchScope.
*/
- ldap_base::Config::SearchScope
- lDAPSearchScope(ldap_base::Config::SearchScope value) override;
+ ConfigIface::SearchScope
+ lDAPSearchScope(ConfigIface::SearchScope value) override;
/** @brief Update the LDAP Type property.
* @param[in] value - lDAPType value to be updated.
* @returns value of changed lDAPType.
*/
- ldap_base::Config::Type lDAPType(ldap_base::Config::Type value) override;
+ ConfigIface::Type lDAPType(ConfigIface::Type value) override;
+
+ /** @brief Update the ldapServiceEnabled property.
+ * @param[in] value - ldapServiceEnabled value to be updated.
+ * @returns value of changed ldapServiceEnabled.
+ */
+ bool enabled(bool value) override;
+
+ /** @brief Update the userNameAttribute property.
+ * @param[in] value - userNameAttribute value to be updated.
+ * @returns value of changed userNameAttribute.
+ */
+ std::string userNameAttribute(std::string value) override;
+
+ /** @brief Update the groupNameAttribute property.
+ * @param[in] value - groupNameAttribute value to be updated.
+ * @returns value of changed groupNameAttribute.
+ */
+ std::string groupNameAttribute(std::string value) override;
/** @brief Delete this D-bus object.
*/
@@ -175,13 +208,19 @@ class ConfigMgr : public CreateIface
* @param[in] lDAPSearchScope - the search scope.
* @param[in] lDAPType - Specifies the LDAP server type which can be AD
or openLDAP.
+ * @param[in] groupNameAttribute - Specifies attribute name that contains
+ * the name of the Group in the LDAP server.
+ * @param[in] usernameAttribute - Specifies attribute name that contains
+ * the username in the LDAP server.
* @returns the object path of the D-Bus object created.
*/
std::string createConfig(std::string lDAPServerURI, std::string lDAPBindDN,
std::string lDAPBaseDN,
std::string lDAPBindDNPassword,
- ldap_base::Create::SearchScope lDAPSearchScope,
- ldap_base::Create::Type lDAPType) override;
+ CreateIface::SearchScope lDAPSearchScope,
+ CreateIface::Type lDAPType,
+ std::string groupNameAttribute,
+ std::string userNameAttribute) override;
/** @brief restarts given service
* @param[in] service - Service to be restarted.
@@ -193,6 +232,12 @@ class ConfigMgr : public CreateIface
*/
virtual void stopService(const std::string& service);
+ /** @brief start or stop the service depending on the given value
+ * @param[in] service - Service to be start/stop.
+ * @param[in] value - true to start the service otherwise stop.
+ */
+ virtual void startOrStopService(const std::string& service, bool value);
+
/** @brief delete the config D-Bus object.
*/
void deleteObject();
OpenPOWER on IntegriCloud