Ldap Server Configuration
Ldap Server Configuration
Ldap Server Configuration
tool
OpenLdap
LDAP Directory Server Installation and configuration. Description: Lightweight Directory
Access Protocol (LDAP) is a means of serving data on individuals, system users, network devices
and systems over the network for e-mail clients, applications requiring authentication or
information.
Uses Of OpenLdap
1- LDAP not only keeps a list of users, you can use it as storage for your files.
2- It can be used for authenticating users as we mentioned above.
3- LDAP can be used as a yellow pages directory service for an organization to provide
information about users or employees, departments, contact information, phone numbers,
addresses, private data or whatever.
What is my setup?
Installing OpenLDAP
1- Install The All Required Packages
# yum install -y openldap openldap-clients openldap-servers
# cd /etc/openldap/slapd.d/cn\=config
4- Find out which files you need to update using the below grep command
# grep my-domain *
5- Open these two files in vi editor and change all occurrences of my-
domain to linuxpert. I opened them and changed it with the following vi
command ":%s/my-domain/linuxpert/"
# vim olcDatabase\=\{1\}monitor.ldif
# vim olcDatabase\=\{2\}hdb.ldif
:%s/my-domain/linuxpert
# slappasswd
New password:
Re-enter new password:
{SSHA}PlOJU60HjF+WTt9/8L10fjPyTugQ79V
Copy the above password hash. We need to add it to one config files. Open up the following one
files and Look for line that starts with olcRootDN.
Add the following line next to this line in the above one files
# vim olcDatabase\=\{2\}hdb.ldif
olcRootDN: cn=Manager,dc=linuxpert,dc=com
olcRootPW: {SSHA}PbLFyieb9d0mPWSEbcfqRs0gMSutJXzE
6- Generate a X509 self sign certificate which is valid for 365 days:
# cd /etc/pki/CA/
# chown ldap:ldap cacert.pem
# cd /etc/pki/CA/private/
# chown ldap:ldap cakey.pem
# chmod 600 cakey.pem
olcRootDN: cn=Manager,dc=linuxpert,dc=com
olcRootPW: {SSHA}PbLFyieb9d0mPWSEbcfqRs0gMSutJXzE
olcTLSCertificateFile: /etc/pki/CA/cacert.pem
olcTLSCertificateKeyFile: /etc/pki/CA/private/cakey.pem
# cp /usr/share/openldap-servers/DB_CONFIG.example /var/lib/ldap/DB_CONFIG
# chown -R ldap.ldap /var/lib/ldap
8- Enable LDAPS
# vim /etc/sysconfig/slapd
# vim /etc/rsyslog.conf
# mkdir /var/log/slapd
# chmod 755 /var/log/slapd
# chown ldap.ldap /var/log/slapd
10- Ldap server uses the following ports. We need to add firewalled rules to
allow connections on port 389 (LDAP) and 636 (LDAPS Add the below
Firewalled rule).
12- Set up first import using ldapadd (Create a file named firstimport.ldif)
# vim firstimport.ldif
dn: dc=linuxpert,dc=com
dc: linuxpert
o: linuxpert
objectclass: dcobject
objectclass: organization
Enter the admin password that you created earlier when asked. This command will add the root
entry to the ldap server.
Now that we have added a single entry, we will verify it by querying the ldap server as below
# ldapsearch -x -b dc=linuxpert,dc=com
# extended LDIF
#
# LDAPv3
# base <dc=linuxpert,dc=com> with scope subtree
# filter: (objectclass=*)
# requesting: ALL
#
# linuxpert.com
dn: dc=linuxpert,dc=com
dc: linuxpert
o: linuxpert
objectClass: dcObject
objectClass: organization
# search result
search: 2
result: 0 Success
# numResponses: 2
# numEntries: 1
If you want to see the actual query output without comments and ldap version information use -
LLL option as shown below.
dn: dc=linuxpert,dc=com
dc: linuxpert
o: linuxpert
objectClass: dcObject
objectClass: organization
Note- Schema file by default added in rhel-6 & Centos-6 and you can check in this location "# ls
/etc/openldap/slapd.d/cn\=config/cn\=schema/") and no need to add this file in rhel-6 &
centos-6.
# cd /etc/openldap/schema
# cd
# vim usersou.ldif
dn: ou=users,dc=linuxpert,dc=com
ObjectClass: organizationalUnit
ou: users
dn: ou=groups,dc=linuxpert,dc=com
ObjectClass: organizationalUnit
ou: groups
We shall add a user to the newly created users organizational unit. Create a file named users.ldif
and enter the below content.
Add user
# vim users.ldif
dn: cn=ashu,ou=groups,dc=linuxpert,dc=com
cn: ashu
objectClass: top
objectClass: posixGroup
gidNumber: 5000
dn: uid=ashu,ou=users,dc=linuxpert,dc=com
cn: Ashu Linux
givenName: Ashu
sn: Linux
uid: ashu
uidNumber: 5003
gidNumber: 5003
homeDirectory: /home/ashu
objectClass: top
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
loginShell: /bin/bash
userPassword: {CRYPT}*
Set up password for the newly created user using the below command
# ldappasswd -x -D "cn=Manager,dc=linuxpert,dc=com" -W -S
"uid=ashu,ou=users,dc=linuxpert,dc=com"
New password: *******
Re-enter new password: ******
Enter LDAP Password: ***************
We are done adding an user and his primary group. Query LDAP for users Lets query the user
we created in the previous step. You can use any of the user fields to query ldap. Try the
following search commands.
dn: uid=ashu,ou=users,dc=linuxpert,dc=com
cn: Ashu Linux
givenName: Ashu
sn: Linux
uid: ashu
uidNumber: 5003
gidNumber: 5003
homeDirectory: /home/ashu
objectClass: top
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
loginShell: /bin/bash
userPassword:: e1NTSEF9NnBrV1pGUlVTT1JDVjVzMkFtdzdhUWtUM2FzUjdDQVM=
OR
dn: uid=ashu,ou=users,dc=linuxpert,dc=com
givenName: Ashu
sn: Linux
uid: ashu
uidNumber: 5003
gidNumber: 5003
homeDirectory: /home/ashu
objectClass: top
objectClass: posixAccount
objectClass: shadowAccount
objectClass: inetOrgPerson
objectClass: organizationalPerson
objectClass: person
loginShell: /bin/bash
userPassword:: e1NTSEF9NnBrV1pGUlVTT1JDVjVzMkFtdzdhUWtUM2FzUjdDQVM=
# ldapdelete -W -D "cn=Manager,dc=linuxpert,dc=com"
"uid=user1,ou=users,dc=linuxpert,dc=com"
http://www.ldapadmin.org/download/ldapadmin.html
Click Ok Ok
Now you can see the Ldap Server
Double click the LDAP Server
Create new user-> Right Click on OU Users -> New User- >
Right Click uid=user1 Set password
-Ashutosh
Reference- https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/5/html/Deployment_Guide/s1-
ldap-pam.html