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
21 if test $BACKMETA = metano ; then
22 echo "meta backend not available, test skipped"
28 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
32 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
34 if test $WAIT != 0 ; then
40 echo "Using ldapsearch to check that slapd is running..."
41 for i in 0 1 2 3 4 5; do
42 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
43 'objectclass=*' > /dev/null 2>&1
45 if test $RC = 0 ; then
48 echo "Waiting 5 seconds for slapd to start..."
51 if test $RC != 0 ; then
52 echo "ldapsearch failed ($RC)!"
53 test $KILLSERVERS != no && kill -HUP $KILLPIDS
57 echo "Using ldapadd to populate the database..."
58 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
59 $LDIFORDERED > $TESTOUT 2>&1
61 if test $RC != 0 ; then
62 echo "ldapadd failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 echo "Starting slapd on TCP/IP port $PORT2..."
68 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
69 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
71 if test $WAIT != 0 ; then
75 KILLPIDS="$KILLPIDS $PID"
77 echo "Using ldapsearch to check that 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..."
88 if test $RC != 0 ; then
89 echo "ldapsearch failed ($RC)!"
90 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Using ldapadd to populate the database..."
95 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
96 $LDIFMETA >> $TESTOUT 2>&1
98 if test $RC != 0 ; then
99 echo "ldapadd failed ($RC)!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Starting slapd on TCP/IP port $PORT3..."
105 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
106 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
108 if test $WAIT != 0 ; then
112 KILLPIDS="$KILLPIDS $PID"
114 echo "Using ldapsearch to check that slapd is running..."
115 for i in 0 1 2 3 4 5; do
116 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
117 'objectclass=*' > /dev/null 2>&1
119 if test $RC = 0 ; then
122 echo "Waiting 5 seconds for slapd to start..."
125 if test $RC != 0 ; then
126 echo "ldapsearch failed ($RC)!"
127 test $KILLSERVERS != no && kill -HUP $KILLPIDS
131 cat /dev/null > $SEARCHOUT
133 BASEDN="o=Example,c=US"
134 echo "Searching base=\"$BASEDN\"..."
135 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
136 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
138 if test $RC != 0 ; then
139 echo "Search failed ($RC)!"
140 test $KILLSERVERS != no && kill -HUP $KILLPIDS
145 # Do some modifications
148 BASEDN="o=Example,c=US"
149 echo "Modifying database \"$BASEDN\"..."
150 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT3 -w $PASSWD \
151 -M >> $TESTOUT 2>&1 << EOMODS
152 # These operations (updates with objectClass mapping) triggered ITS#3499
153 dn: cn=Added Group,ou=Groups,$BASEDN
155 objectClass: groupOfNames
156 objectClass: uidObject
158 member: cn=Added Group,ou=Groups,$BASEDN
161 dn: cn=Another Added Group,ou=Groups,$BASEDN
163 objectClass: groupOfNames
164 cn: Another Added Group
165 member: cn=Added Group,ou=Groups,$BASEDN
166 member: cn=Another Added Group,ou=Groups,$BASEDN
168 dn: cn=Another Added Group,ou=Groups,$BASEDN
171 objectClass: uidObject
177 dn: cn=Added Group,ou=Groups,$BASEDN
180 objectClass: uidObject
188 description: added to "ou=Meta,$BASEDN"
191 dn: ou=Who's going to handle this?,$BASEDN
193 objectClass: organizationalUnit
194 ou: Who's going to handle this?
196 description: will be deleted
198 dn: ou=Same as above,$BASEDN
200 objectClass: organizationalUnit
202 description: added right after "Who's going to handle this?"
203 description: will be preserved
205 dn: ou=Who's going to handle this?,$BASEDN
208 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
210 objectClass: organizationalUnit
211 ou: Who's going to handle this?
213 description: will be deleted
215 dn: ou=Same as above,ou=Meta,$BASEDN
217 objectClass: organizationalUnit
219 description: added right after "Who's going to handle this?"
220 description: will be preserved
222 dn: cn=Added User,ou=Same as above,ou=Meta,$BASEDN
224 objectClass: inetOrgPerson
229 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
234 if test $RC != 0 ; then
235 echo "Modify failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 echo "Searching base=\"$BASEDN\"..."
241 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
242 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
244 if test $RC != 0 ; then
245 echo "Search failed ($RC)!"
246 test $KILLSERVERS != no && kill -HUP $KILLPIDS
250 BASEDN="o=Example,c=US"
251 echo " base=\"$BASEDN\"..."
252 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
253 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" -M "$FILTER" '*' ref \
256 if test $RC != 0 ; then
257 echo "Search failed ($RC)!"
258 test $KILLSERVERS != no && kill -HUP $KILLPIDS
262 BASEDN="o=Example,c=US"
263 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
264 echo "Searching filter=\"$FILTER\""
265 echo " attrs=\"seeAlso\""
266 echo " base=\"$BASEDN\"..."
267 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
268 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
269 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
270 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" seeAlso \
273 if test $RC != 0 ; then
274 echo "Search failed ($RC)!"
275 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 FILTER="(uid=example)"
280 echo "Searching filter=\"$FILTER\""
281 echo " attrs=\"uid\""
282 echo " base=\"$BASEDN\"..."
283 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
284 echo "# attrs=\"uid\"" >> $SEARCHOUT
285 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
286 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" uid \
289 if test $RC != 0 ; then
290 echo "Search failed ($RC)!"
291 test $KILLSERVERS != no && kill -HUP $KILLPIDS
295 FILTER="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
296 echo "Searching filter=\"$FILTER\""
297 echo " attrs=\"member\""
298 echo " base=\"$BASEDN\"..."
299 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
300 echo "# attrs=\"member\"" >> $SEARCHOUT
301 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
302 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" member \
305 if test $RC != 0 ; then
306 echo "Search failed ($RC)!"
307 test $KILLSERVERS != no && kill -HUP $KILLPIDS
311 echo "Filtering ldapsearch results..."
312 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
313 echo "Filtering original ldif used to create database..."
314 . $LDIFFILTER < $METAOUT > $LDIFFLT
315 echo "Comparing filter output..."
316 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
318 if test $? != 0 ; then
319 echo "comparison failed - meta search/modification didn't succeed"
320 test $KILLSERVERS != no && kill -HUP $KILLPIDS
324 BASEDN="o=Example,c=US"
325 echo "Changing password to database \"$BASEDN\"..."
326 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
327 -s $PASSWD "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
330 if test $RC != 0 ; then
331 echo "Passwd ExOp failed ($RC)!"
332 test $KILLSERVERS != no && kill -HUP $KILLPIDS
336 echo "Binding with newly changed password to database \"$BASEDN\"..."
337 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
338 -D "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
339 -w $PASSWD >> $TESTOUT 2>&1
341 if test $RC != 0 ; then
342 echo "WhoAmI failed ($RC)!"
343 test $KILLSERVERS != no && kill -HUP $KILLPIDS
347 echo "Binding as newly added user to database \"$BASEDN\"..."
348 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
349 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
350 -w $PASSWD >> $TESTOUT 2>&1
352 if test $RC != 0 ; then
353 echo "WhoAmI failed ($RC)!"
354 test $KILLSERVERS != no && kill -HUP $KILLPIDS
358 echo "Changing password to database \"$BASEDN\"..."
359 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
360 -s meta "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
363 if test $RC != 0 ; then
364 echo "Passwd ExOp failed ($RC)!"
365 test $KILLSERVERS != no && kill -HUP $KILLPIDS
369 echo "Binding with newly changed password to database \"$BASEDN\"..."
370 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
371 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
372 -w meta >> $TESTOUT 2>&1
374 if test $RC != 0 ; then
375 echo "WhoAmI failed ($RC)!"
376 test $KILLSERVERS != no && kill -HUP $KILLPIDS
380 echo "Comparing to database \"$BASEDN\"..."
381 $LDAPCOMPARE -h $LOCALHOST -p $PORT3 \
382 "cn=Another Added Group,ou=Groups,$BASEDN" \
383 "member:cn=Added Group,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
385 if test $RC != 6 ; then
386 echo "Compare failed ($RC)!"
387 test $KILLSERVERS != no && kill -HUP $KILLPIDS
391 test $KILLSERVERS != no && kill -HUP $KILLPIDS
393 echo ">>>>> Test succeeded"