3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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"
24 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
26 echo "Running slapadd to build slapd database..."
27 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $ADDCONF
28 . $CONFFILTER < $LDIFCHAIN1 > $SEARCHOUT
29 $SLAPADD -f $ADDCONF -l $SEARCHOUT
31 if test $RC != 0 ; then
32 echo "slapadd 1 failed ($RC)!"
36 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $ADDCONF
37 . $CONFFILTER < $LDIFCHAIN2 > $SEARCHOUT
38 $SLAPADD -f $ADDCONF -l $SEARCHOUT
40 if test $RC != 0 ; then
41 echo "slapadd 2 failed ($RC)!"
45 echo "Starting first slapd on TCP/IP port $PORT1..."
46 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF1 > $CONF1
47 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
49 if test $WAIT != 0 ; then
54 echo "Starting second slapd on TCP/IP port $PORT2..."
55 . $CONFFILTER $BACKEND $MONITORDB < $CHAINCONF2 > $CONF2
56 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
58 if test $WAIT != 0 ; then
63 KILLPIDS="$PID1 $PID2"
67 echo "Using ldapsearch to check that first slapd is running..."
68 for i in 0 1 2 3 4 5; do
69 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
70 'objectclass=*' > /dev/null 2>&1
72 if test $RC = 0 ; then
75 echo "Waiting 5 seconds for slapd to start..."
79 echo "Using ldapsearch to check that second slapd is running..."
80 for i in 0 1 2 3 4 5; do
81 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
82 'objectclass=*' > /dev/null 2>&1
84 if test $RC = 0 ; then
87 echo "Waiting 5 seconds for slapd to start..."
91 for P in $PORT1 $PORT2 ; do
92 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
93 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
97 if test $RC != 0 ; then
98 echo "ldapsearch failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 echo "Filtering ldapsearch results..."
104 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
105 echo "Filtering original ldif used to create database..."
106 . $LDIFFILTER < $CHAINOUT > $LDIFFLT
107 echo "Comparing filter output..."
108 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
110 if test $? != 0 ; then
111 echo "comparison failed - chained search didn't succeed"
112 test $KILLSERVERS != no && kill -HUP $KILLPIDS
116 echo "Reading the referral entry "ou=Other,$BASEDN" as anonymous on port $P..."
117 $LDAPSEARCH -h $LOCALHOST -p $P -b "ou=Other,$BASEDN" -S "" \
121 if test $RC != 0 ; then
122 echo "ldapsearch failed ($RC)!"
123 test $KILLSERVERS != no && kill -HUP $KILLPIDS
127 echo "Filtering ldapsearch results..."
128 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
129 echo "Filtering original ldif used to create database..."
130 . $LDIFFILTER < $CHAINREFOUT > $LDIFFLT
131 echo "Comparing filter output..."
132 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
134 if test $? != 0 ; then
135 echo "comparison failed - chained search didn't succeed"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 DN="cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN"
141 echo "Comparing \"$DN\" on port $P..."
142 $LDAPCOMPARE -h $LOCALHOST -p $P "$DN" "cn:Mark Elliot" \
146 if test $RC != 6 ; then
147 echo "ldapcompare failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 DN="ou=Other,$BASEDN"
153 echo "Comparing \"$DN\" on port $P with manageDSAit control..."
154 $LDAPCOMPARE -h $LOCALHOST -p $P -M "$DN" "ou:Other" \
158 if test $RC != 6 ; then
159 echo "ldapcompare failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
166 # Testing writes to first server
168 echo "Writing to first server with scope on second server..."
169 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
170 $TESTOUT 2>&1 << EOMODS
171 dn: cn=New Group,ou=Groups,dc=example,dc=com
173 objectClass: groupOfNames
177 dn: cn=New Group,ou=Groups,dc=example,dc=com
180 description: testing chain overlay writes...
183 member: cn=New Group,ou=Groups,dc=example,dc=com
184 member: cn=Manager,dc=example,dc=com
187 owner: cn=Manager,dc=example,dc=com
190 dn: cn=New Group,ou=Groups,dc=example,dc=com
192 newrdn: cn=Renamed Group
195 dn: cn=All Staff,ou=Groups,dc=example,dc=com
200 if test $RC != 0 ; then
201 echo "ldapmodify failed ($RC)!"
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 # Testing writes to second server
209 echo "Writing to second server with scope on first server..."
210 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
211 $TESTOUT 2>&1 << EOMODS
212 dn: cn=New User,ou=People,dc=example,dc=com
217 seeAlso: cn=New Group,ou=Groups,dc=example,dc=com
219 dn: cn=New User,ou=People,dc=example,dc=com
222 description: testing chain overlay writes...
225 seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
228 dn: cn=New User,ou=People,dc=example,dc=com
230 newrdn: cn=Renamed User
233 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
238 if test $RC != 0 ; then
239 echo "ldapmodify failed ($RC)!"
240 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 for P in $PORT1 $PORT2 ; do
245 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
246 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
250 if test $RC != 0 ; then
251 echo "ldapsearch failed ($RC)!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
256 echo "Filtering ldapsearch results..."
257 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
258 echo "Filtering original ldif used to create database..."
259 . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT
260 echo "Comparing filter output..."
261 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
263 if test $? != 0 ; then
264 echo "comparison failed - chained search didn't succeed"
265 test $KILLSERVERS != no && kill -HUP $KILLPIDS
271 echo "Using ldappasswd on second server with scope on first server..."
272 $LDAPPASSWD -h $LOCALHOST -p $PORT2 \
273 -w secret -s $NEWPW \
274 -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1
276 if test $RC != 0 ; then
277 echo "ldappasswd failed ($RC)!"
278 test $KILLSERVERS != no && kill -HUP $KILLPIDS
282 echo "Binding with newly changed password on first server..."
283 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
284 -D "$BJORNSDN" -w $NEWPW
286 if test $RC != 0 ; then
287 echo "ldapwhoami failed ($RC)!"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 test $KILLSERVERS != no && kill -HUP $KILLPIDS
294 echo ">>>>> Test succeeded"