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"
65 echo "Using ldapsearch to check that first slapd is running..."
66 for i in 0 1 2 3 4 5; do
67 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
68 'objectclass=*' > /dev/null 2>&1
70 if test $RC = 0 ; then
73 echo "Waiting 5 seconds for slapd to start..."
77 echo "Using ldapsearch to check that second slapd is running..."
78 for i in 0 1 2 3 4 5; do
79 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
80 'objectclass=*' > /dev/null 2>&1
82 if test $RC = 0 ; then
85 echo "Waiting 5 seconds for slapd to start..."
89 for P in $PORT1 $PORT2 ; do
90 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
91 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
95 if test $RC != 0 ; then
96 echo "ldapsearch failed ($RC)!"
97 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Filtering ldapsearch results..."
102 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
103 echo "Filtering original ldif used to create database..."
104 . $LDIFFILTER < $CHAINOUT > $LDIFFLT
105 echo "Comparing filter output..."
106 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
108 if test $? != 0 ; then
109 echo "comparison failed - chained search didn't succeed"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Reading the referral entry "ou=Other,$BASEDN" as anonymous on port $P..."
115 $LDAPSEARCH -h $LOCALHOST -p $P -b "ou=Other,$BASEDN" -S "" \
119 if test $RC != 0 ; then
120 echo "ldapsearch failed ($RC)!"
121 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 echo "Filtering ldapsearch results..."
126 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
127 echo "Filtering original ldif used to create database..."
128 . $LDIFFILTER < $CHAINREFOUT > $LDIFFLT
129 echo "Comparing filter output..."
130 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
132 if test $? != 0 ; then
133 echo "comparison failed - chained search didn't succeed"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 DN="cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN"
139 echo "Comparing \"$DN\" on port $P..."
140 $LDAPCOMPARE -h $LOCALHOST -p $P "$DN" "cn:Mark Elliot"
144 if test $RC != 0 ; then
145 echo "ldapcompare failed ($RC)!"
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 DN="ou=Other,$BASEDN"
151 echo "Comparing \"$DN\" on port $P with manageDSAit control..."
152 $LDAPCOMPARE -h $LOCALHOST -p $P -M "$DN" "ou:Other"
156 if test $RC != 0 ; then
157 echo "ldapcompare failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 # Testing writes to first server
166 echo "Writing to first server with scope on second server..."
167 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
168 $TESTOUT 2>&1 << EOMODS
169 dn: cn=New Group,ou=Groups,dc=example,dc=com
171 objectClass: groupOfNames
175 dn: cn=New Group,ou=Groups,dc=example,dc=com
178 description: testing chain overlay writes...
181 member: cn=New Group,ou=Groups,dc=example,dc=com
182 member: cn=Manager,dc=example,dc=com
185 owner: cn=Manager,dc=example,dc=com
188 dn: cn=New Group,ou=Groups,dc=example,dc=com
190 newrdn: cn=Renamed Group
193 dn: cn=All Staff,ou=Groups,dc=example,dc=com
198 if test $RC != 0 ; then
199 echo "ldapmodify failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
205 # Testing writes to second server
207 echo "Writing to second server with scope on first server..."
208 $LDAPMODIFY -v -D "$MANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD > \
209 $TESTOUT 2>&1 << EOMODS
210 dn: cn=New User,ou=People,dc=example,dc=com
215 seeAlso: cn=New Group,ou=Groups,dc=example,dc=com
217 dn: cn=New User,ou=People,dc=example,dc=com
220 description: testing chain overlay writes...
223 seeAlso: cn=Renamed Group,ou=Groups,dc=example,dc=com
226 dn: cn=New User,ou=People,dc=example,dc=com
228 newrdn: cn=Renamed User
231 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,dc=example,dc=com
236 if test $RC != 0 ; then
237 echo "ldapmodify failed ($RC)!"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 for P in $PORT1 $PORT2 ; do
243 echo "Testing ldapsearch as anonymous for \"$BASEDN\" on port $P..."
244 $LDAPSEARCH -h $LOCALHOST -p $P -b "$BASEDN" -S "" \
248 if test $RC != 0 ; then
249 echo "ldapsearch failed ($RC)!"
250 test $KILLSERVERS != no && kill -HUP $KILLPIDS
254 echo "Filtering ldapsearch results..."
255 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
256 echo "Filtering original ldif used to create database..."
257 . $LDIFFILTER < $CHAINMODOUT > $LDIFFLT
258 echo "Comparing filter output..."
259 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
261 if test $? != 0 ; then
262 echo "comparison failed - chained search didn't succeed"
263 test $KILLSERVERS != no && kill -HUP $KILLPIDS
269 echo "Using ldappasswd on second server with scope on first server..."
270 $LDAPPASSWD -h $LOCALHOST -p $PORT2 \
271 -w secret -s $NEWPW \
272 -D "$MANAGERDN" "$BJORNSDN" >> $TESTOUT 2>&1
274 if test $RC != 0 ; then
275 echo "ldappasswd failed ($RC)!"
276 test $KILLSERVERS != no && kill -HUP $KILLPIDS
280 echo "Binding with newly changed password on first server..."
281 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
282 -D "$BJORNSDN" -w $NEWPW
284 if test $RC != 0 ; then
285 echo "ldapwhoami failed ($RC)!"
286 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo ">>>>> Test succeeded"