CIT 470 Advanced Network and System Administration: Lab #7: LDAP | |||||||
|
|||||||
In this lab, we'll install and configure an LDAP server. We'll also configure the virtual machine to be an LDAP client. The LDAP HOWTO is a useful reference.
yum install openldap-servers openldap-clients
ls /var/lib/ldap
cd /etc/openldap ls -l
cp -p slapd.conf slapd.conf.dist
vim slapd.conf
service ldap start
service ldap status ps auxw | grep ldap
cd /etc/openldap cp -p ldap.conf ldap.conf.dist
vim /etc/openldap/ldap.conf
ldapsearch -x -LL -b '' -s base '(objectclass=*)'The output of the command should look like this, since we haven't added any data to our server.
version: 1 dn: objectClass: top objectClass: OpenLDAProotDSE
ldapsearch -x -LL -b '' -s base '(objectclass=*)' namingContextsThe output of the command should look like this:
version: 1 dn: namingContexts: dc=cit470,dc=nku,dc=edu
reboot
service ldap status
The root node describes the organization as a whole. The distinguished name (DN) of the root node must be identical to the root DN you specified in /etc/openldap/slapd.conf above.
# Root node dn: dc=cit470,dc=nku,dc=edu objectclass: organization objectclass: dcObject o: cit470.nku.edu dc: cit470The branch nodes describe departments within the organization. In our case, there is only one level of branch nodes, but there can be as many levels as you would like to have. Each branch and leaf node is uniquely identified by a DN consisting of a relative DN (ou=AcademicComputing in the node immediately below) followed by the directory's root DN. The DN serves the same purpose as a pathname or URL. Note that the objectclass of the branch nodes is organizationUnit. The leaf nodes will be of a different objectclass.
# AcademicComputing branch node dn: ou=AcademicComputing, dc=cit470,dc=nku,dc=edu objectclass: organizationalUnit ou: AcademicComputing # Informatics branch node dn: ou=Informatics, dc=cit470,dc=nku,dc=edu objectclass: organizationalUnit ou: InformaticsThere is a special leaf node for the LDAP directory's superuser. This node belongs to the special objectclass called organizationalRole, as it describes a role, not a person in the organization.
# LDAP Superuser node dn: cn=Manager, dc=cit470,dc=nku,dc=edu objectclass: organizationalRole cn: ManagerThe majority of nodes are leaf nodes that describe individual data objects, which belong to objectclass person. LDAP directories don't have to store information about persons. Leaf nodes could as easily be used to describe computers and other hardware devices in your inventory.
# AcademicComputing leaf nodes dn: cn=To Fu, ou=AcademicComputing, dc=cit470,dc=nku,dc=edu objectclass: person cn: To Fu sn: Fu dn: cn=Fu Bar, ou=AcademicComputing, dc=cit470,dc=nku,dc=edu objectclass: person cn: Fu Bar sn: Bar # Informatics leaf nodes dn: cn=Peter Python, ou=Informatics, dc=cit470,dc=nku,dc=edu objectclass: person cn: Peter Python sn: Python dn: cn=Ann Anaconda, ou=Informatics, dc=cit470,dc=nku,dc=edu objectclass: person cn: Ann Anaconda sn: Anaconda dn: cn=Valerie Viper, ou=Informatics, dc=cit470,dc=nku,dc=edu objectclass: person cn: Valerie Viper cn: Val Viper sn: Viper
ldapadd -x -D "cn=Manager,dc=cit470,dc=nku,dc=edu" -W -f example.ldif
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(cn=*)'
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(cn=*Python)'
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(sn=Python)'
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(objectclass=person)'
grep ldap /etc/services
vim /etc/sysconfig/iptablesEach line that you add to the configuration file should look like the following line with the appropriate port number used in place of the word LDAP_PORT. Be sure to add the lines to the appropriate part of the configuration file.
-A RH-Firewall-1-INPUT -m state --state NEW -p tcp --dport LDAP_PORT -j ACCEPT
service iptables restart
yum install openldap-clients
cd /etc/openldap cp -p ldap.conf ldap.conf.dist
vim /etc/openldap/ldap.conf
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(objectclass=person)'
*.=debug /var/log/debugthen restart the syslog service. Once syslog has restarted, you can watch the debug log while attempting the query again.
tail -f /var/log/debug
ldapsearch -x -LL -b 'dc=cit470,dc=nku,dc=edu' '(objectclass=person)'