{"id":4778,"date":"2019-11-15T23:12:53","date_gmt":"2019-11-15T20:12:53","guid":{"rendered":"https:\/\/kifarunix.com\/?p=4778"},"modified":"2024-03-12T23:15:36","modified_gmt":"2024-03-12T20:15:36","slug":"how-to-create-openldap-member-groups","status":"publish","type":"post","link":"https:\/\/kifarunix.com\/how-to-create-openldap-member-groups\/","title":{"rendered":"How to Create OpenLDAP Member Groups"},"content":{"rendered":"\n<p>While assigning specific access rights or permissions to users whose access to various organization systems or resources are controlled via directory or identity management tools like <a rel=\"noreferrer noopener\" aria-label=\"OpenLDAP (opens in a new tab)\" href=\"https:\/\/www.openldap.org\/doc\/admin24\/intro.html\" target=\"_blank\">OpenLDAP<\/a> or <a rel=\"noreferrer noopener\" aria-label=\"FreeIPA (opens in a new tab)\" href=\"https:\/\/www.freeipa.org\/page\/About\" target=\"_blank\">FreeIPA<\/a>, it is more feasible and less time consuming to manage this as a group. In this guide, we are going to learn how to Create OpenLDAP Member Groups to enable you to control what a specific group of members are authorized to do on a given organization system or resource.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Creating OpenLDAP Member Groups<\/h2>\n\n\n\n<p>Before you can proceed with this guide, we assume that you already have an OpenLDAP server up and running. Otherwise, you can check our OpenLDAP guides by following the links below;<\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/install-and-setup-openldap-on-centos-8\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">Install and Setup OpenLDAP on CentOS 8<\/a><\/p>\n\n\n\n<p><a href=\"https:\/\/kifarunix.com\/how-to-configure-sudo-via-openldap-server\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How to Configure SUDO via OpenLDAP Server<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/configure-sssd-for-openldap-authentication-on-centos-8\/\" target=\"_blank\">Configure SSSD for OpenLDAP Authentication on CentOS 8<\/a><\/p>\n\n\n\n<p>Well, so how do you create member groups on OpenLDAP?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Enabling OpenLDAP memberof Overlay<\/h3>\n\n\n\n<p>The OpenLDAP group membership is provided by the <code>memberof<\/code> overlay. An <a rel=\"noreferrer noopener\" aria-label=\"overlay (opens in a new tab)\" href=\"https:\/\/www.openldap.org\/doc\/admin24\/overlays.html\" target=\"_blank\">overlay<\/a> is component of OpenLDAP that is used to perform functions similar to the functions provided by an OpenLDAP database backends.<\/p>\n\n\n\n<p>Overlays can be dynamically loaded via the overlays modules or can be compiled directly into OpenLDAP database, slapd.<\/p>\n\n\n\n<p>To check if the <code>memberof overlay<\/code> module has already been loaded.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -LLL -Y EXTERNAL -H ldapi:\/\/\/ -b  cn=config -LLL | grep -i module<\/code><\/pre>\n\n\n\n<p>As you can see in the output below, only MDB database backend module is loaded.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\nSASL\/EXTERNAL authentication started\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\n<strong># module{0}, config\ndn: cn=module{0},cn=config\nobjectClass: olcModuleList\ncn: module{0}\nolcModulePath: \/usr\/libexec\/openldap\nolcModuleLoad: {0}back_mdb.la<\/strong>\n...\n<\/code><\/pre>\n\n\n\n<p>Find the location of the memberof overlay module and confirm if matches the already specified path above. The path below might be different in your case.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>find \/ -iname memberof.la<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/libexec\/openldap\/memberof.la<\/code><\/pre>\n\n\n\n<p>Therefore, update the slapd database with the memberof overlay module by creating an ldif file as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim update-module.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dn: cn=module{0},cn=config\nchangetype: modify\nadd: olcModuleLoad\nolcModuleLoad: memberof.la<\/code><\/pre>\n\n\n\n<p>Load the module into slapd.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f update-module.ldif<\/code><\/pre>\n\n\n\n<p>If you do not want to update the existing module, you can add another module directory information tree.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim load-memberof-module.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>dn: cn=module,cn=config\ncn: module\nobjectClass: olcModuleList\nolcModuleLoad: memberof.la\nolcModulePath: \/usr\/libexec\/openldap<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f load-memberof-module.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SASL\/EXTERNAL authentication started\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\nadding new entry \"cn=module,cn=config\"<\/code><\/pre>\n\n\n\n<p>Verify again that the module is loaded.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -LLL -Y EXTERNAL -H ldapi:\/\/\/ -b  cn=config -LLL | grep -i module<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\ndn: cn=module{0},cn=config\nobjectClass: olcModuleList\ncn: module{0}\nolcModulePath: \/usr\/libexec\/openldap\n<strong>olcModuleLoad: {0}back_mdb.la\nolcModuleLoad: {1}memberof.la<\/strong>\n...\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Add memberof Overlay to SLAPD database<\/h3>\n\n\n\n<p>Now that the memberof overlay modules is loaded, you then need to update it on OpenLDAP database.<\/p>\n\n\n\n<p>The overlay should be updated on a specific database backend. To locate your database backend, you can simply run the command. In our case, we are using MDB database hence grep mdb.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -LLL -Y EXTERNAL -H ldapi:\/\/\/ -b  cn=config olcDatabase | grep mdb<\/code><\/pre>\n\n\n\n<p>Note the sequential order of your database schema.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SASL\/EXTERNAL authentication started\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\ndn: <strong>olcDatabase={1}mdb,cn=config<\/strong>\nolcDatabase: {1}mdb<\/code><\/pre>\n\n\n\n<p>Create an LDIF file with your memberof overlay attributes as shown below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim add-memberof-overlay.ldif<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>dn: olcOverlay=memberof,olcDatabase={1}mdb,cn=config\nobjectClass: olcMemberOf\nobjectClass: olcOverlayConfig\nobjectClass: olcConfig\nobjectClass: top\nolcOverlay: memberof \nolcMemberOfRefInt: TRUE\nolcMemberOfDangling: ignore\nolcMemberOfGroupOC: groupOfNames\nolcMemberOfMemberAD: member\nolcMemberOfMemberOfAD: memberOf\n<\/code><\/pre>\n\n\n\n<p>For more information on the overlay attributes used above, consult, <code>man slapo-memberof<\/code>.<\/p>\n\n\n\n<p>Update the OpenLDAP database with memberof overlay attributes.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f add-memberof-overlay.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>SASL\/EXTERNAL authentication started\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\nadding new entry \"olcOverlay=memberof,olcDatabase={1}mdb,cn=config\"<\/code><\/pre>\n\n\n\n<p>Another important aspect of OpenLDAP group membership is the Referential Integrity. Consider the line <code><strong>olcMemberOfRefInt: TRUE<\/strong><\/code>. This line basically enables what is called <a rel=\"noreferrer noopener\" aria-label=\"referential integrity (opens in a new tab)\" href=\"https:\/\/linux.die.net\/man\/5\/slapo-refint\" target=\"_blank\">referential integrity<\/a> which ensures that the integrity of the database schema is kept. For example, if any attributes of a member are adjusted, all the groups on which the member belongs are also updated.<\/p>\n\n\n\n<p>Referential Integrity is also managed by an overlay which has to be loaded via a module.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>find \/ -iname refint.la<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>\/usr\/libexec\/openldap\/refint.la<\/code><\/pre>\n\n\n\n<p>Since the module location is the same, you can simply load the <code>refint<\/code> module as follows;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim add-refint.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dn: cn=module{0},cn=config\nchangetype: modify\nadd: olcModuleLoad\nolcModuleLoad: refint.la<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f add-refint.ldif<\/code><\/pre>\n\n\n\n<p>Read more on <code>man slapo-refint<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create OpenLDAP Member Groups<\/h3>\n\n\n\n<p>The OpenLDAP memberof overlay is now setup. The next step is to create member groups to enable you impose specific access control authorization.<\/p>\n\n\n\n<p>Assuming you have the following users in your OpenLDAP database, for example;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nuid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code><\/pre>\n\n\n\n<p>To create openldap member group with the above users as members, you can use an LDIF file as shown below;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim member-group.ldif<\/code><\/pre>\n\n\n\n<p>Note that we have already created a Group OU, <code>ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code>, in our case. As such, this ldif will will simply create a group called <code><strong>admins<\/strong><\/code> with the above users as members.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>\ndn: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: groupOfNames\ncn: admins\nmember: uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmember: uid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f member-group.ldif<\/code><\/pre>\n\n\n\n<p>Check that the group is created;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" cn=admins<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\ndn: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: groupOfNames\ncn: admins\nmember: uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmember: uid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n<\/code><\/pre>\n\n\n\n<p>The&nbsp;<strong>memberOf <\/strong>attribute&nbsp;is automatically added to user entries to indicate a group that the user belongs to. You can search the members using the memberOf attribute.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" memberOf<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"add-users-to-ldap-group\"><a href=\"#add-users-to-ldap-group\">Add OpenLDAP Users to Groups<\/a><\/h3>\n\n\n\n<p>You can as well add members to specific groups using the <code>memberOf<\/code> attribute. For example, to add the user, <code>janedoe<\/code> to the <code>admins<\/code> groups created above;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim memberof.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dn: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nchangetype: modify\nadd: memberOf\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code><\/pre>\n\n\n\n<p>The update the slapd database;<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f memberof.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" uid=* memberOf<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>SASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\n<strong>dn: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/strong>\n\ndn: uid=johndoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\n\n<strong>dn: uid=linus,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/strong>\n\n<strong>dn: uid=koromicha,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com\nmemberOf: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/strong>\n<\/code><\/pre>\n\n\n\n<p>Well, you now have OpenLDAP groups and members added.<\/p>\n\n\n\n<p>How do you authenticate to LDAP connected systems as a group via SSSD?<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Setup OpenLDAP SSSD Group Authentication<\/h3>\n\n\n\n<p>Now that you have setup your member groups, let us see how you can configure SSSD on your LDAP clients for group authentication.<\/p>\n\n\n\n<p>Assuming you already installed SSSD on your OpenLDAP clients, edit the SSSD main configuration file, <code>\/etc\/sssd\/sssd.conf<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim \/etc\/sssd\/sssd.conf<\/code><\/pre>\n\n\n\n<p>Below is our sample SSSD configuration. Note that we restrict access only to members of the admins group we created above using the <code>memberOf<\/code> attribute as the value of <code>ldap_access_filter<\/code>. Also note the access provider, <code>access_provider = ldap<\/code>.<\/p>\n\n\n\n<pre class=\"scroll-box\"><code>[sssd]\nservices = nss, pam, sudo\nconfig_file_version = 2\ndomains = default\n\n[sudo]\n\n[nss]\n\n[pam]\noffline_credentials_expiration = 60\n\n[domain\/default]\nldap_id_use_start_tls = True\ndebug_level = 10\ncache_credentials = True\nldap_search_base = dc=ldapmaster,dc=kifarunix-demo,dc=com\nid_provider = ldap\nauth_provider = ldap\nchpass_provider = ldap\naccess_provider = ldap\nsudo_provider = ldap\nldap_uri = ldaps:\/\/ldapmaster.kifarunix-demo.com:636\nldap_default_bind_dn = cn=readonly,ou=system,dc=ldapmaster,dc=kifarunix-demo,dc=com\nldap_default_authtok = P@ssW0rd\nldap_tls_reqcert = demand\nldap_tls_cacert = \/etc\/ssl\/certs\/cacert.crt\nldap_tls_cacertdir = \/etc\/ssl\/certs\nldap_search_timeout = 50\nldap_network_timeout = 60\nldap_sudo_search_base = ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\nldap_access_order = filter\nldap_access_filter = <strong>memberOf=cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/strong>\n<\/code><\/pre>\n\n\n\n<p>You other configuration options might be different as with the above configuration, but the <code>memberOf<\/code> attribute should be there to define the   group of members allowed access. Read more on man <code>sssd-ldap<\/code> for a more description on SSSD options.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test SSSD Authentication as a Group Member<\/h3>\n\n\n\n<p>Once you have defined your memberOf access filter, try to authenticate as member of the admins group.<\/p>\n\n\n\n<p>Clear SSSD cache.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>systemctl stop sssd;rm -rf \/var\/lib\/sss\/db\/*;systemctl start sssd<\/code><\/pre>\n\n\n\n<p>Now, login as one member of the admins group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ssh linus@192.168.56.103<\/code><\/pre>\n\n\n\n<p>Where:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The IP address specified here is the OpenLDAP client with SSSD configuration above.<\/li>\n\n\n\n<li><code>linus<\/code> is a user member of the admins group.<\/li>\n<\/ul>\n\n\n\n<pre class=\"scroll-box\"><code>The authenticity of host '192.168.56.103 (192.168.56.103)' can't be established.\nECDSA key fingerprint is SHA256:HMMbAonHoAVgZwbYi7KY4O7jXH+h9GMDDwy1kI2LyGM.\nAre you sure you want to continue connecting (yes\/no)? yes\nWarning: Permanently added '192.168.56.103' (ECDSA) to the list of known hosts.\nlinus@192.168.56.103's password: \nCreating directory '\/home\/linus'.\nWelcome to Ubuntu 18.04 LTS (GNU\/Linux 4.15.0-20-generic x86_64)\n\n * Documentation:  https:\/\/help.ubuntu.com\n * Management:     https:\/\/landscape.canonical.com\n * Support:        https:\/\/ubuntu.com\/advantage\n\n\n * Canonical Livepatch is available for installation.\n   - Reduce system reboots and improve kernel security. Activate at:\n     https:\/\/ubuntu.com\/livepatch\n\nThe programs included with the Ubuntu system are free software;\nthe exact distribution terms for each program are described in the\nindividual files in \/usr\/share\/doc\/*\/copyright.\n\nUbuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by\napplicable law.\n\nLast login: Thu Dec 12 04:13:48 2019 from ::1\nlinus@ubuntu18:~$\n<\/code><\/pre>\n\n\n\n<p>There you go.<\/p>\n\n\n\n<p>Try to authenticate as user who is not a member of the admins group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ssh johndoe@192.168.56.103<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>johndoe@192.168.56.103's password: password here\nConnection to 192.168.56.103 closed by remote host.\nConnection to 192.168.56.103 closed.<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Set Access Control Lists for OpenLDAP Member Group<\/h3>\n\n\n\n<p>You can also assign specific access controls to a group of members on OpenLDAP.<\/p>\n\n\n\n<p>What am demoing here is not actually group access controls. But let us see how to give members of a specific group sudo rights via OpenLDAP. Learn<a rel=\"noreferrer noopener\" aria-label=\" how to configure OpenLDAP support for sudo first (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/how-to-configure-sudo-via-openldap-server\/\" target=\"_blank\"> how to configure OpenLDAP SUDO support here first<\/a>.<\/p>\n\n\n\n<p>We already created a sudoers role on our LDAP server called, <code>sudo<\/code> with one member given sudo rights.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" cn=sudo<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>SASL\/EXTERNAL authentication started\nSASL username: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth\nSASL SSF: 0\ndn: cn=sudo,ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: top\nobjectClass: sudoRole\ncn: sudo\n<strong>sudoUser: johndoe<\/strong>\nsudoHost: ALL\nsudoRunAsUser: ALL\nsudoCommand: ALL\n<\/code><\/pre>\n\n\n\n<p>Now, modify your sudo role (if already existing) and add one of the users from the admins group.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>vim addtosudo.ldif<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>dn: cn=sudo,ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\nchangetype: modify\nadd: sudoUser\nsudoUser: linus<\/code><\/pre>\n\n\n\n<p>Update the database.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapadd -Y EXTERNAL -H ldapi:\/\/\/ -f addtosudo.ldif<\/code><\/pre>\n\n\n\n<p>Verify the sudo group membership.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>ldapsearch -H ldapi:\/\/\/ -Y EXTERNAL -LLL -b \"dc=ldapmaster,dc=kifarunix-demo,dc=com\" cn=sudo<\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>dn: cn=sudo,ou=SUDOers,dc=ldapmaster,dc=kifarunix-demo,dc=com\nobjectClass: top\nobjectClass: sudoRole\ncn: sudo\n<strong>sudoUser: johndoe\nsudoUser: linus<\/strong>\nsudoHost: ALL\nsudoRunAsUser: ALL\nsudoCommand: ALL\n<\/code><\/pre>\n\n\n\n<p>Now, since only members of <code>admins<\/code> group are allowed to authenticate, only user, <code>linus<\/code> has been given sudo rights as defined above.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>root@ubuntu18:~# <strong>sudo -U linus -ll<\/strong><\/code><\/pre>\n\n\n\n<pre class=\"scroll-box\"><code>Matching Defaults entries for linus on ubuntu18:\n    !visiblepw, always_set_home, match_group_by_gid, always_query_group_plugin, env_reset, env_keep =  \"COLORS DISPLAY HOSTNAME HISTSIZE KDEDIR\n    LS_COLORS\", env_keep += \"MAIL PS1 PS2 QTDIR USERNAME LANG LC_ADDRESS LC_CTYPE\", env_keep += \"LC_COLLATE LC_IDENTIFICATION LC_MEASUREMENT\n    LC_MESSAGES\", env_keep += \"LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER LC_TELEPHONE\", env_keep += \"LC_TIME LC_ALL LANGUAGE LINGUAS _XKB_CHARSET\n    XAUTHORITY\", env_keep+=SSH_AUTH_SOCK, secure_path = \/sbin:\/bin:\/usr\/sbin:\/usr\/bin, env_reset, mail_badpass,\n    secure_path=\/usr\/local\/sbin\\:\/usr\/local\/bin\\:\/usr\/sbin\\:\/usr\/bin\\:\/sbin\\:\/bin\\:\/snap\/bin\n\nUser linus may run the following commands on ubuntu18:\n\nSSSD Role: sudo\n    RunAsUsers: ALL\n    Commands:\n\tALL\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>root@ubuntu18:~# <strong>sudo -U koromicha -ll\nUser koromicha is not allowed to run sudo on ubuntu18.<\/strong><\/code><\/pre>\n\n\n\n<p>Well, there you. You have learn to create OpenLDAP member groups via the memberof overlay module as well as adding other users to member groups and even defining specific access controls for respective members of the group.<\/p>\n\n\n\n<p>Extras;<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How to Delete Users from an OpenLDAP Group<\/h3>\n\n\n\n<p>You can also delete or remove users from OpenLDAP groups.<\/p>\n\n\n\n<p>For example, to remove the user <strong><code>uid=janedoe<\/code><\/strong> from the <code>admins<\/code> group;<\/p>\n\n\n\n<p>Run the command below on the terminal;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ldapmodify -Y EXTERNAL -H ldapi:\/\/\/ -QQQ<\/code><\/pre>\n\n\n\n<p>Press enter on the terminal to execute the command above<\/p>\n\n\n\n<p>Copy the following, modify to fit your environment setup and paste and press enter to execute.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>dn: cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\ndelete: member\nmember: uid=janedoe,ou=people,dc=ldapmaster,dc=kifarunix-demo,dc=com<\/code><\/pre>\n\n\n\n<p>You should see the output;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>modifying entry \"cn=admins,ou=groups,dc=ldapmaster,dc=kifarunix-demo,dc=com\"<\/code><\/pre>\n\n\n\n<p>Press Ctrl+c to stop the command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Other tutorials<\/h3>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/setup-openldap-server-with-ssl-tls-on-debian-10\/\" target=\"_blank\">Setup OpenLDAP Server with SSL\/TLS on Debian 10<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-configure-openldap-server-on-fedora-29\/\" target=\"_blank\">Install and Configure OpenLDAP server on Fedora 29<\/a><\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\" href=\"https:\/\/kifarunix.com\/install-and-setup-freeipa-server-on-centos-8\/\" target=\"_blank\">Install and Setup FreeIPA Server on CentOS 8<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>While assigning specific access rights or permissions to users whose access to various organization systems or resources are controlled via directory or identity management tools<\/p>\n","protected":false},"author":1,"featured_media":10430,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,285,1099],"tags":[5392,5390,1246,1226,5391,1223,1227,1225,1217,1224],"class_list":["post-4778","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-directory-server","category-openldap","tag-changetype-modify","tag-delete-user-from-openldap-group","tag-ldap-member-groups","tag-ldap-memberof-overlay","tag-ldapmodify","tag-memberof","tag-memberof-attribute","tag-openldap-groups","tag-openldap-sudo","tag-sssd-memberof-access-filter","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4778"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=4778"}],"version-history":[{"count":11,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4778\/revisions"}],"predecessor-version":[{"id":21258,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/4778\/revisions\/21258"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/10430"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=4778"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=4778"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=4778"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}