Remove user from a group OpenLDAP command line

Remove user from a group OpenLDAP command line

Remove user from a group OpenLDAP command line

If an end-user changes position, or gets transfered, you may need to remove them from an LDAP group. Here’s the basic process

Login, and su to root

Root shell prompt on the ldapdemo OpenLDAP server

change directory to /tmp to manipulate the LDAP database

vi ldapdb at the root prompt in /tmp

from here we are going to take a dump of the LDAP database

Same screenshot: vi ldapdb, shown where the step says to dump the LDAP database

vi the LDAP database

Same screenshot: vi ldapdb to open the LDAP dump

in this scenario, we want to remove our use John from the Finance Group, so we locate the Finance Group

Finance group entry: cn=Finance,ou=groups,dc=mydomain,dc=local, gidNumber 502, posixGroup, memberUid john

from here hit ctrl+c and type the following:

vi command :set nu to show line numbers

this shows the line numbers, now hit ctrl+c again and type the following:

vi Finance at the root prompt, shown where the step writes line 49 to a file

this takes line 49, and writes it to a file called Finance, edit the file once done

Same screenshot: vi Finance, shown where the step says to edit the Finance file

from here we have to set-up the file to delete the user

Same screenshot: vi Finance, shown where the step sets up the file to delete the member

once that’s all setup, we need to commit the change to the database

ldapmodify -x -D cn=admin,dc=mydomain,dc=local -W -f Finance typed to commit the change

run the command, authenticate as the LDAP admin

ldapmodify output: Enter LDAP Password, modifying entry cn=Finance,ou=groups,dc=mydomain,dc=local

Successfully modified/removed the user, now we just have to check, by re-dumping LDAP

ldapsearch -x > ldapdb to re-dump LDAP and check john was removed from Finance

perfect, John has been removed from the group!

That’s it!

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Add user to a group OpenLDAP command line | Remove user from openLDAP command line

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *