Building a new LDAP server today… lots of fun. I decided to put together some docs of what I was doing. So here they are:
Configuring OpenLDAP on Suse Linux
The purpose of this document is to describe how to use OpenLDAP is to use LDAP as a back-end database, or user information repository, for IEEE 802.1x port authentication. In an IEEE 802.1x-enabled environment, user credential information is validated against a user-database by the authentication-server, which runs RADIUS. The authentication-server receives authentication attempts from the end-user via the authenticator (a LAN switch or wireless AP).
Note � it is best practice to ensure that a good copy of any system configuration file is saves before starting. Make backup copies of all system configuration files!
Once the system is installed, updated, and normalized, start by editing /etc/openldap/ldap.conf. Add the following entries:
HOST 127.0.0.1
BASE dc=company,dc=com
Save this file, and open slapd.conf in the same directory. Edit the following:
#######################################################################
# bdb database definitions
#######################################################################
database bdb
checkpoint 1024 5
cachesize 10000
suffix “dc=company,dc=com”
rootdn “cn=Manager,dc=company,dc=com”
# Cleartext passwords, especially for the rootdn, should
# be avoid. See slappasswd(8) and slapd.conf(5) for details.
# Use of strong authentication encouraged.
#rootpw secret
rootpw {MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==
# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
directory /var/lib/ldap
# Indices to maintain
index objectClass eq
The rootpw can be generated by using the slappasswd command.
linuxhost:~ # slappasswd -h {MD5}
New password:
Re-enter new password:
{MD5}Xr4ilOzQ4PCOq3aQ0qbuaQ==
linuxhost:~ #
Start the Server
From the command shell, initialize the LDAP server.
linuxhost:~ # /etc/rc.d/ldap start
Starting ldap-server done
linuxhost:~ #
Populating the LDAP Database
PADL Software Ltd. has a collection of Perl tools that can be used to convert configuration files to LDIF format. Some distributions (such as Redhat/Fedora) include these tools, but apparently Suse does not. These tools are normally located in /usr/share/openldap/migration. If these tools were not included in the distribution being used, they can be downloaded from:
http://www.padl.com/OSS/MigrationTools.html
Installation is simple.
untar zxf MigrationTools.tgz
cd MigrationTools-44
Open the migrate_common.ph file and change the following site-specific variables to reflect the installation:
# Default DNS domain
$DEFAULT_MAIL_DOMAIN = “company.com”;
# Default base
$DEFAULT_BASE = “dc=company,dc=com
Once this is complete, use the migrate_base.pl script to create an LDIF file with the base entries needed to start LDAP:
linuxhost:/usr/share/openldap/migration # ./migrate_base.pl > base.ldif
linuxhost:/usr/share/openldap/migration #
If all goes well, the command prompt should return with no messages. Once this is complete, check the base.ldif file to ensure the proper information is included before it is imported into the LDAP database. The file should look like this:
linuxhost:/usr/share/openldap/migration # more base.ldif
dn: dc=company,dc=com
dc: company
objectClass: top
objectClass: domain
dn: ou=Hosts,dc=company,dc=com
ou: Hosts
objectClass: top
objectClass: organizationalUnit
dn: ou=Rpc,dc=company,dc=com
ou: Rpc
objectClass: top
objectClass: organizationalUnit
dn: ou=Services,dc=company,dc=com
ou: Services
objectClass: top
objectClass: organizationalUnit
dn: nisMapName=netgroup.byuser,dc=company,dc=com
nismapname: netgroup.byuser
objectClass: top
objectClass: nisMap
dn: ou=Mounts,dc=company,dc=com
ou: Mounts
objectClass: top
objectClass: organizationalUnit
dn: ou=Networks,dc=company,dc=com
ou: Networks
objectClass: top
objectClass: organizationalUnit
dn: ou=People,dc=company,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit
dn: ou=Group,dc=company,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit
dn: ou=Netgroup,dc=company,dc=com
ou: Netgroup
objectClass: top
objectClass: organizationalUnit
dn: ou=Protocols,dc=company,dc=com
ou: Protocols
objectClass: top
objectClass: organizationalUnit
dn: ou=Aliases,dc=company,dc=com
ou: Aliases
objectClass: top
objectClass: organizationalUnit
dn: nisMapName=netgroup.byhost,dc=company,dc=com
nismapname: netgroup.byhost
objectClass: top
objectClass: nisMap
linuxhost:/usr/share/openldap/migration #
Copy the base.ldif into root’s home directory.
Once the base.ldif file has been validated, import the file into the blank LDAP database using the ldapadd tool:
linuxhost:~ # ldapadd -x -D “cn=Manager,dc=company,dc=com” -W -f /root/base.ldif
Enter LDAP Password:
adding new entry “ou=Hosts,dc=company,dc=com”
adding new entry “ou=Rpc,dc=company,dc=com”
adding new entry “ou=Services,dc=company,dc=com”
adding new entry “nisMapName=netgroup.byuser,dc=company,dc=com”
adding new entry “ou=Mounts,dc=company,dc=com”
adding new entry “ou=Networks,dc=company,dc=com”
adding new entry “ou=People,dc=company,dc=com”
adding new entry “ou=Group,dc=company,dc=com”
adding new entry “ou=Netgroup,dc=company,dc=com”
adding new entry “ou=Protocols,dc=company,dc=com”
adding new entry “ou=Aliases,dc=company,dc=com”
adding new entry “nisMapName=netgroup.byhost,dc=company,dc=com”
linuxhost:~ #
Validating Database
Using the ldapsearch tool, the integrity of the data that was just imported can be validated.
linuxhost:/var/lib/ldap # ldapsearch -x -b ‘dc=company,dc=com’ ‘objectclass=*’
# extended LDIF
#
# LDAPv3
# base
# filter: objectclass=*
# requesting: ALL
#
# company.com
dn: dc=company,dc=com
dc: company
description: Root LDAP entry for LAB at company.com
objectClass: dcObject
objectClass: organizationalUnit
ou: rootobject
# Hosts, company.com
dn: ou=Hosts,dc=company,dc=com
ou: Hosts
objectClass: top
objectClass: organizationalUnit
# Rpc, company.com
dn: ou=Rpc,dc=company,dc=com
ou: Rpc
objectClass: top
objectClass: organizationalUnit
# Services, company.com
dn: ou=Services,dc=company,dc=com
ou: Services
objectClass: top
objectClass: organizationalUnit
# netgroup.byuser, company.com
dn: nisMapName=netgroup.byuser,dc=company,dc=com
nisMapName: netgroup.byuser
objectClass: top
objectClass: nisMap
# Mounts, company.com
dn: ou=Mounts,dc=company,dc=com
ou: Mounts
objectClass: top
objectClass: organizationalUnit
# Networks, company.com
dn: ou=Networks,dc=company,dc=com
ou: Networks
objectClass: top
objectClass: organizationalUnit
# People, company.com
dn: ou=People,dc=company,dc=com
ou: People
objectClass: top
objectClass: organizationalUnit
# Group, company.com
dn: ou=Group,dc=company,dc=com
ou: Group
objectClass: top
objectClass: organizationalUnit
# Netgroup, company.com
dn: ou=Netgroup,dc=company,dc=com
ou: Netgroup
objectClass: top
objectClass: organizationalUnit
# Protocols, company.com
dn: ou=Protocols,dc=company,dc=com
ou: Protocols
objectClass: top
objectClass: organizationalUnit
# Aliases, company.com
dn: ou=Aliases,dc=company,dc=com
ou: Aliases
objectClass: top
objectClass: organizationalUnit
# netgroup.byhost, company.com
dn: nisMapName=netgroup.byhost,dc=company,dc=com
nisMapName: netgroup.byhost
objectClass: top
objectClass: nisMap
# production, company.com
dn: ou=production,dc=company,dc=com
ou: production
objectClass: top
objectClass: organizationalUnit
objectClass: posixGroup
gidNumber: 3001
# search result
search: 2
result: 0 Success
# numResponses: 15
# numEntries: 14
linuxhost:/var/lib/ldap #
This output should roughly match the contents of the base.ldif file that was imported earlier.
Management
While the command-line tools included with the server are functional, LDAP lends itself well to a GUI environment because of its hierarchical nature. Several graphical interfaces are available, but many of them rely on java-capable or proprietary endpoint software clients to operate.
PHPLDAPAdmin is an open-source web-based tool used to administer an LDAP server. It is available to download from:
http://phpldapadmin.sourceforge.net/download.php
Simply untar the package and copy the directory into the root of the webserver to install. Once this is complete, copy the config.php.example file to config.php in the directory, and then make the following edits to the following variables:
$servers[$i]['name'] = ‘Test Lab Server’;
$servers[$i]['host'] = ‘localhost’;
$servers[$i]['base'] = ‘dc=company,dc=com’;
$servers[$i]['login_dn'] = ‘cn=Manager,dc=company,dc=com’;
$servers[$i]['login_pass'] = ‘secret’;
There are other variables to change, however, to get �up and running� with PHPLDAPAdmin, these are the minimum changes necessary. Once these changes are complete, simply open a web-browser and point it to the directory where PHPLDAPAdmin was installed.