OpenLDAP - Installation (for CentOS/RedHat 7.x) and setup
Assuming that the domain is dev.dept.example.com (for example.com just use dc=example,dc=com)
- Install OpenLDAP
yum install -y openldap openldap-clients openldap-servers
- Start slapd service
systemctl start slapd
systemctl enable slapd
- Create db.ldif file with below content
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcSuffix
olcSuffix: dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootDN
olcRootDN: cn=Manager,dc=example,dc=com
dn: olcDatabase={2}hdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: ldappassw
- Add configurations using:
ldapmodify -Y EXTERNAL -H ldapi:/// -f db.ldif
- Do a LDAP shearch
ldapsearch -x -b "dc=example,dc=com"
- Create a base.ldif file
#messaging node
dn: ou=messaging,dc=example,dc=com
objectclass: top
objectclass: organizationalUnit
ou: messaging
- Create the base using
ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f base.ldif
- Create users.ldif with below content
dn: ou=users,ou=messaging,dc=example,dc=com
objectclass: top
objectclass: organizationalUnit
ou: users
- Create users OU using:
ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f users.ldif
- Create a user admin in the OU users using admin.ldif
dn: uid=admin,ou=users,ou=messaging,dc=example,dc=com
cn: admin
displayname:
gidnumber: 0
givenname: admin
homedirectory: /home/admin
loginshell: admin
objectclass: posixAccount
objectclass: top
objectclass: inetOrgPerson
sn: admin
uid: admin
uidnumber: 27600
userpassword: admin
- Add user to the ldap db
ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f admin.ldif
- Create groups OU using groups.ldif
dn: ou=groups,ou=messaging,dc=example,dc=com
objectclass: top
objectclass: organizationalUnit
ou: groups
- Add groups OU to the ldap db
ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f groups.ldif
- Add admins group and users to OU groups using admins.ldif
dn: cn=admins,ou=groups,ou=messaging,dc=example,dc=com
cn: admins
member: uid=admin,ou=users,ou=messaging,dc=example,dc=com
objectclass: groupOfNames
- Add admins.ldif using
ldapadd -x -W -D "cn=Manager,dc=example,dc=com" -f admins.ldif