[[ldap]]
 

Setting up your first OpenLDAP server

This was done on Redhat AS 3.0 and Fedora Core 3. Other platforms may require more dependency issues to be solved. Download Berkeley DB and the OpenLDAP tar.gz file to /usr/local/src, then:

cd /usr/local/src
tar zxvf db-4.3.27.NC.tar.gz
cd db-4.3.27.NC/build_unix
../dist/configure
make
make install

cd /usr/local/src
tar zxvf openldap-2.2.24.tar.gz
cd openldap-2.2.24/
mkdir /usr/local/openldap
export LD_LIBRARY_PATH=/usr/local/BerkeleyDB.4.3/lib
export PATH=$PATH:/usr/local/BerkeleyDB.4.3/bin
export LDFLAGS=-L/usr/local/BerkeleyDB.4.3/lib
export CPPFLAGS=-I/usr/local/BerkeleyDB.4.3/include/
./configure --prefix=/usr/local/openldap --enable-crypt
make depend
make install

OpenLDAP is now installed in /usr/local/openldap. Next thing you need to do is installed a basic LDAP config file and Root tree. In /usr/local/openldap/etc/openldap/slapd.conf add the following lines:

include         /usr/local/openldap/etc/openldap/schema/cosine.schema
include         /usr/local/openldap/etc/openldap/schema/inetorgperson.schema

#######################################################################
# BDB database definitions
#######################################################################

database        bdb
suffix          "dc=example,dc=com"
rootdn          "cn=Manager,dc=example,dc=com"
rootpw		secret

Start slapd with /usr/local/openldap/libexec/slapd. You should now be able to connect to localhost, port 389 with your favourite LDAP client and authenticate as “cn=Manager,dc=example,dc=com” with a password of “secret”.

Next, add some entries into the Root tree to make it into a useful LDAP database. Create a file called foo.ldif and populate it with:

## Setup the root node:
dn: dc=example,dc=com
dc: example
objectClass: dcObject
objectClass: organizationalUnit
ou: Example Dot Com

## Build the people ou.
dn: ou=people,dc=example,dc=com
ou: people
objectClass: organizationalUnit

## First basic entry
dn: cn=Gavin,ou=people,dc=example,dc=com
objectClass: inetOrgPerson
cn: Gavin
sn: Kelman
mail: gavin@metahusky.net
UserPassword: password
Add this entry into the LDAP database with:
/usr/local/openldap/bin/ldapadd -W -x -D cn=Manager,dc=example,dc=com -f foo.ldif
To modify an entry, create an ldif file with the following contents:
dn: cn=Gavin,ou=people,dc=example,dc=com
changetype: modify
add: mail
mail: gavin@example.com

This will add an extra “mail” entry into cn=Gavin,ou=people,dc=example,dc=com , when you run:

/usr/local/openldap/bin/ldapamodify -W -x -D cn=Manager,dc=example,dc=com -f modify.ldif

Check if your LDAP directory is OK by retrieving every entry in the directory:

/usr/local/openldap/bin/ldapsearch -x -b 'dc=example,dc=com' '(objectclass=*)'

For further information, consult “LDAP System Administration” from O’Reilly, and the OpenLDAP Quick-Start Guide

 
ldap.txt · Last modified: 2006/10/02 12:28 by gavin
 
Recent changes RSS feed Valid XHTML 1.0 Valid CSS Driven by DokuWiki