3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2007 The OpenLDAP Foundation.
6 ## All rights reserved.
8 ## Redistribution and use in source and binary forms, with or without
9 ## modification, are permitted only as authorized by the OpenLDAP
12 ## A copy of this license is available in the file LICENSE in the
13 ## top-level directory of the distribution or, alternatively, at
14 ## <http://www.OpenLDAP.org/license.html>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 if test $BACKLDAP = "ldapno" ; then
20 echo "LDAP backend not available, test skipped"
26 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
28 echo "Running slapadd to build slapd database..."
29 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $ADDCONF
30 . $CONFFILTER < $LDIFCHAIN1 > $SEARCHOUT
31 $SLAPADD -f $ADDCONF -l $SEARCHOUT
33 if test $RC != 0 ; then
34 echo "slapadd 1 failed ($RC)!"
38 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $ADDCONF
39 . $CONFFILTER < $LDIFCHAIN2 > $SEARCHOUT
40 $SLAPADD -f $ADDCONF -l $SEARCHOUT
42 if test $RC != 0 ; then
43 echo "slapadd 2 failed ($RC)!"
47 echo "Starting first slapd on TCP/IP port $PORT1..."
48 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $CONF1
49 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
51 if test $WAIT != 0 ; then
57 echo "Starting second slapd on TCP/IP port $PORT2..."
58 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
59 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
61 if test $WAIT != 0 ; then
66 KILLPIDS="$KILLPIDS $PID2"
70 echo "Using ldapsearch to check that first slapd is running..."
71 for i in 0 1 2 3 4 5; do
72 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
73 'objectclass=*' > /dev/null 2>&1
75 if test $RC = 0 ; then
78 echo "Waiting 5 seconds for slapd to start..."
82 if test $RC != 0 ; then
83 echo "ldapsearch failed ($RC)!"
84 test $KILLSERVERS != no && kill -HUP $KILLPIDS
88 echo "Using ldapsearch to check that second slapd is running..."
89 for i in 0 1 2 3 4 5; do
90 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
91 'objectclass=*' > /dev/null 2>&1
93 if test $RC = 0 ; then
96 echo "Waiting 5 seconds for slapd to start..."
100 if test $RC != 0 ; then
101 echo "ldapsearch failed ($RC)!"
102 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 for P in $PORT1 $PORT2 ; do
107 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
108 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
112 if test $RC != 0 ; then
113 echo "ldapsearch failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
118 echo "Filtering ldapsearch results..."
119 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
120 echo "Filtering original ldif used to create database..."
121 . $LDIFFILTER < $CHAINOUT > $LDIFFLT
122 echo "Comparing filter output..."
123 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
125 if test $? != 0 ; then
126 echo "comparison failed - chained search didn't succeed"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 echo "Reading the referral entry "ou=Other,$BASEDN" as anonymous on port $P..."
132 $LDAPSEARCH -h $LOCALHOST -p $P -b "ou=Other,$BASEDN" -S "" \
136 if test $RC != 0 ; then
137 echo "ldapsearch failed ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
142 echo "Filtering ldapsearch results..."
143 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
144 echo "Filtering original ldif used to create database..."
145 . $LDIFFILTER < $CHAINREFOUT > $LDIFFLT
146 echo "Comparing filter output..."
147 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
149 if test $? != 0 ; then
150 echo "comparison failed - chained search didn't succeed"
151 test $KILLSERVERS != no && kill -HUP $KILLPIDS
155 DN="cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN"
156 echo "Comparing \"$DN\" on port $P..."
157 $LDAPCOMPARE -h $LOCALHOST -p $P "$DN" "cn:Mark Elliot" \
161 if test $RC != 6 ; then
162 echo "ldapcompare failed ($RC)!"
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 DN="ou=Other,$BASEDN"
168 echo "Comparing \"$DN\" on port $P with manageDSAit control..."
169 $LDAPCOMPARE -h $LOCALHOST -p $P -M "$DN" "ou:Other" \
173 if test $RC != 6 ; then
174 echo "ldapcompare failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
181 # Testing writes to first server
183 echo "Writing to first server with scope on second server..."
184 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
185 $TESTOUT 2>&1 << EOMODS
186 dn: cn=New Group,ou=Groups,dc=example,dc=com
188 objectClass: groupOfNames
192 dn: cn=New Group,ou=Groups,dc=example,dc=com
195 description: testing chain overlay writes...
198 member: cn=New Group,ou=Groups,dc=example,dc=com
199 member: cn=Manager,dc=example,dc=com
202 owner: cn=Manager,dc=example,dc=com
205 dn: cn=New Group,ou=Groups,dc=example,dc=com
207 newrdn: cn=Renamed Group
210 dn: cn=All Staff,ou=Groups,dc=example,dc=com
215 if test $RC != 0 ; then
216 echo "ldapmodify failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
222 # Testing writes to second server
224 echo "Writing to second server with scope on first server..."
225 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
226 $TESTOUT 2>&1 << EOMODS
227 dn: cn=New User,ou=People,dc=example,dc=com
232 seeAlso: cn=New Group,ou=Groups,dc=example,dc=com
234 dn: cn=New User,ou=People,dc=example,dc=com
237 description: testing chain overlay writes...
240 seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
243 dn: cn=New User,ou=People,dc=example,dc=com
245 newrdn: cn=Renamed User
248 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
253 if test $RC != 0 ; then
254 echo "ldapmodify failed ($RC)!"
255 test $KILLSERVERS != no && kill -HUP $KILLPIDS
259 for P in $PORT1 $PORT2 ; do
260 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
261 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
265 if test $RC != 0 ; then
266 echo "ldapsearch failed ($RC)!"
267 test $KILLSERVERS != no && kill -HUP $KILLPIDS
271 echo "Filtering ldapsearch results..."
272 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
273 echo "Filtering original ldif used to create database..."
274 . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT
275 echo "Comparing filter output..."
276 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
278 if test $? != 0 ; then
279 echo "comparison failed - chained search didn't succeed"
280 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 echo "Using ldappasswd on second server with scope on first server..."
287 $LDAPPASSWD -h $LOCALHOST -p $PORT2 \
288 -w secret -s $NEWPW \
289 -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1
291 if test $RC != 0 ; then
292 echo "ldappasswd failed ($RC)!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
297 echo "Binding with newly changed password on first server..."
298 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
299 -D "$BJORNSDN" -w $NEWPW
301 if test $RC != 0 ; then
302 echo "ldapwhoami failed ($RC)!"
303 test $KILLSERVERS != no && kill -HUP $KILLPIDS
307 test $KILLSERVERS != no && kill -HUP $KILLPIDS
309 echo ">>>>> Test succeeded"
311 test $KILLSERVERS != no && wait