Manage your users from one place

[root@openldap ~]# yum install -y openldap openldap-clients openldap-servers

Now you have to edit file /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{2\}hdb.ldif

olcSuffix: dc=setenforce,dc=com
olcRootDN: cn=Manager,dc=setenforce,dc=com Manager is admin account for LDAP
olcRootPW: pillow pillow is manager password

Set admin user and password for the config database. This require to change /etc/openldap/slapd.d/cn\=config/olcDatabase\=\{0\}config.ldif

olcRootDN: cn=config
olcRootPW: pillow

Now, we can create the base structure of the ldap server. For this purpose I am using initial.ldif file with next content

dn: dc=setenforce,dc=com
objectClass: dcObject
objectClass: organization
dc: setenforce

dn: ou=users,dc=setenforce,dc=com
objectClass: organizationalUnit
objectClass: top
ou: users

dn: ou=groups,dc=setenforce,dc=com
objectClass: organizationalUnit
objectClass: top
ou: groups

Load initial.ldif in your ldap server

[root@openldap openldap]# ldapadd -x -D "cn=Manger,dc=setenforce,dc=com" -f -w pillow initial.ldif

It is time to create first user. Create user.ldif file with next content

dn: uid=jelena,ou=users,dc=setenforce,dc=com
uid: jelena
cn: jelena
objectClass: account
objectClass: posixAccount
objectClass: top
objectClass: shadowAccount
objectClass: extensibleObject
userPassword: {crypt}$6$q7gTDlTg$kkGr1UtzZp6VkDh0DdcmHEpRxwjQxxzKCmhr4nFrrs/vPn1z95PpqRIBJNwpN0Q0Rm9HouvRBY4TLwRdXMZqm0
shadowLastChange: 17016
shadowMin: 0
shadowMax: 99999
shadowWarning: 7
loginShell: /bin/bash
uidNumber: 1001
gidNumber: 1001
homeDirectory: /home/jelena

Load created ldif to LDAP.

[root@openldap slapd.d]# ldapadd -x -D "cn=Manager,dc=setenforce,dc=com" -w pillow -f users.ldif

If you want to change password for user, you can use next command

[root@openldap openldap]# ldappasswd -x -D "cn=Manger,dc=setenforce,dc=com" -W -S "uid=jelena,ou=users,dc=setenforce,dc=com"