Add an OU to OpenLDAP command line

Add an OU to OpenLDAP command line

Add an OU to OpenLDAP command line

This blog goes through the basic process of adding an OU to your LDAP environment via Command Line. Let’s get Started, login, and su to root

Root shell prompt on the ldapdemo OpenLDAP server

from here change to the /tmp directory to allow easy manipulation of the LDAP database.

cd /tmp on the LDAP server

from here create a new file called “SkyNet” as that’s the name of the OU we are going to add

Same screenshot: cd /tmp, shown where the step says to create the SkyNet file

now vi the file

vi SkyNet in /tmp to create the LDIF file for the new OU

here’s the basic syntax for the file

LDIF: dn ou=SkyNet,dc=mydomain,dc=local, changetype add, objectClass organizationalUnit, ou SkyNet

run the following command to create the new OU in the LDAP Database

ldapadd -x -D cn=admin,dc=mydomain,dc=local -W -f SkyNet

cool, so apparently SkyNet has been added to the LDAP database

ldapadd prompting Enter LDAP Password, then adding new entry ou=SkyNet,dc=mydomain,dc=local

let’s double check to make sure by doing an LDAP dump

ldapsearch -x > ldapdb to dump the directory to a file

from here vi the ldapdb

vi ldapdb to open the LDAP dump

look at that, we have become self-aware of SkyNet being in the LDAP database.

LDAP dump showing the new entry dn: ou=SkyNet,dc=mydomain,dc=local, objectClass organizationalUnit

That’s it!

Hosted Linux Servers at www.zwiegnet.com/go

Related guides: Remove an OU from OpenLDAP command line | Add Group to LDAP command line

Leave a Reply

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