This page gives some guidelines on testing theLdapPlugin extension, and provides some examples about deployingOpenLDAP to perform thetests.
The examples in this page assume that you are working with a Linux server (Debian), with OpenLDAP 2.2 or greater.
Theslapd
server should be installed and you should also have access to the Ldap utils, which usually come with a separate package:
slapadd
,slapcat
ldapsearch
,ldapadd
,ldapmodify
,ldapdelete
All the commands are run using the superuser (root) account.
The following config file is somewhat more complex than it could be, as it uses ACL, etc. However this is a good base to elaborate a more complexLDAP setup and which is the file I used to test the extension.
# BDB backend in this exampledatabase bdb# Maximum entries returned in a searchsizelimit 100# Log connections, operations, results# Do not forget to reduce the debug level once everything is up and running !loglevel 768suffix "dc=example,dc=org"rootdn "uid=root,dc=example,dc=org"# Cleartext password: Tracrootpw {SSHA}yGq6aHM4w3Hf94hl4j+1rgO3HSGmmbVqlastmod on# Path to the database filesdirectory /var/local/db/tracldap# 1.3.6.1.4.1.15527 is reserved. Do not hijack it# Please see http://www.iana.org/cgi-bin/enterprise.pl# Attribute type definitionsattributetype ( 1.3.6.1.4.1.15527.143 NAME 'tracperm' DESC 'Trac Permission' EQUALITY caseIgnoreMatch SUBSTR caseIgnoreSubstringsMatch SYNTAX 1.3.6.1.4.1.1466.115.121.1.15{32} )# Class definitionsobjectclass ( 1.3.6.1.4.1.15527.8 NAME 'tracuser' DESC 'Regular user with Trac permission' SUP top STRUCTURAL MUST ( uid $ cn $ userpassword ) MAY ( tracperm $ sn $ description ) )objectclass ( 1.3.6.1.4.1.15527.9 NAME 'tracgroup' DESC 'Trac permission for groupofnames' SUP top AUXILIARY MAY ( tracperm ) )# ACLs (warning: give read access to anonymous LDAP connection)access to dn.base="" by * readaccess to dn.base="cn=subschema" by * readaccess to filter=(|(objectclass=groupOfNames)(objectclass=tracuser)) dn.one="dc=example,dc=org" by group="cn=managers,dc=example,dc=org" write by * readaccess to attrs=tracperm by group="cn=managers,dc=example,dc=org" write by self read by users read by anonymous readaccess to attrs=entry dn.subtree="dc=example,dc=org" by * read# Search indexingindex objectClass,uid eqindex cn,sn eq,sub,pres,approxindex member eq
You should include this file from the main OpenLDAP configuration file, usually located here:/etc/ldap/slapd.conf
. You need to include these definitions at the bottom of the file.
OpenLDAP errors can be cryptic. You can find useful information however in the log produced by the server.
It is useful to compare requests made by standard utilities such asldapsearch
and the requests made by the extension: if an ldapsearch request fails, blame your server configuration (or your directory content) not the Trac Ldap Extension.
/etc/syslog.conf
:# Log OpenLDAPlocal4.* -/var/log/openldap.all
/etc/init.d/sysklogd reload
tail -f /var/log/openldap.all
mkdir /var/local/db/tracldap
/etc/init.d/slapd start
You should not get any error. If you get an error message (carefully check the log file), please fix up yourLDAP configuration before resuming installation.
If everything is ok, shut down the server, because we need to initialize theLDAP directory before continuing.
We need to create the top-most entry (the localroot) of theLDAP hierarchical directory.
init.ldif
for example:dn: dc=example,dc=orgdc: exampleo: Tracdescription: Test directory for TracobjectClass: dcObjectobjectClass: organization
/usr/sbin/slapadd -b "dc=example,dc=org" -l init.ldif
/etc/init.d/slapd start
Now that the server is up and running, we can inject the initial directory entries that are expected by the extension unit tests.
dirtest.ldif
:# Group definition# Managers is a group that has permission to add and revoke Trac permissionsdn: cn=managers,dc=example,dc=orgcn: managersobjectClass: groupOfNamesobjectClass: tracgroupmember: uid=trac,dc=example,dc=org# Group definition# Users is a group of regular usersdn: cn=users,dc=example,dc=orgcn: usersobjectClass: groupOfNamesobjectClass: tracgroupmember: uid=joeuser,dc=example,dc=org# User definition# Trac is the 'software user' that manages the Trac permissionsdn: uid=trac,dc=example,dc=orguid: traccn: Trac ManageruserPassword: TracobjectClass: tracuser# Special 'user': anonymous# joker entry for non authenticated accessdn: uid=anonymous,dc=example,dc=orguid: anonymouscn: Trac Anonymoussn: AnonymoususerPassword: no_useobjectClass: tracuser# Special 'user': authenticated# joker entry for any authenticated accessdn: uid=authenticated,dc=example,dc=orguid: authenticatedcn: Trac Authenticatedsn: AuthenticateduserPassword: no_useobjectClass: tracuser# User definition# Joe User is just a regular userdn: uid=joeuser,dc=example,dc=orguid: joeusercn: Joe Usersn: UseruserPassword: anypasswdobjectClass: tracuser
ldapadd -D "uid=root,dc=example,dc=org" -x -W -f direst.ldif
You'll be prompted for the user password, ie the password for useruid=root
. This password is defined in theLDAP directory config file, hereTrac
.
Now you should be able to fully use the directory:
ldapsearch -b "dc=example,dc=org" -x objectclass=*
Trac
too):ldapsearch -b "dc=example,dc=org" -D "uid=trac,dc=example,dc=org" -x -W objectclass=*
If the test fails or some part of the installation procedure fails, you want to clean up theLDAP directory to restart from a clean environment.
/etc/init.d/slapd stop
rm /var/local/db/tracldap/*
OpenLDAP server is sensitive to its configuration settings, so double check your configuration files and your LDIF files if you encounter errors in the early setup stage.
slapadd: could not parse entry (line=n)
, which usually means that your initial LDIF file is malformed:ldapsearch
returns no result:slapd
server.