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
42 echo "Using ldapsearch to check that slapd is running..."
43 for i in 0 1 2 3 4 5; do
44 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
45 'objectclass=*' > /dev/null 2>&1
47 if test $RC = 0 ; then
50 echo "Waiting 5 seconds for slapd to start..."
53 if test $RC != 0 ; then
54 echo "ldapsearch failed ($RC)!"
55 test $KILLSERVERS != no && kill -HUP $KILLPIDS
59 echo "Using ldapadd to populate the database..."
60 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
61 $LDIFORDERED > $TESTOUT 2>&1
63 if test $RC != 0 ; then
64 echo "ldapadd failed ($RC)!"
65 test $KILLSERVERS != no && kill -HUP $KILLPIDS
69 echo "Starting slapd on TCP/IP port $PORT2..."
70 . $CONFFILTER $BACKEND $MONITORDB < $METACONF2 > $CONF2
71 $SLAPD -f $CONF2 -h $URI2 -d $LVL $TIMING > $LOG2 2>&1 &
73 if test $WAIT != 0 ; then
77 KILLPIDS="$KILLPIDS $PID"
81 echo "Using ldapsearch to check that slapd is running..."
82 for i in 0 1 2 3 4 5; do
83 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT2 \
84 'objectclass=*' > /dev/null 2>&1
86 if test $RC = 0 ; then
89 echo "Waiting 5 seconds for slapd to start..."
92 if test $RC != 0 ; then
93 echo "ldapsearch failed ($RC)!"
94 test $KILLSERVERS != no && kill -HUP $KILLPIDS
98 echo "Using ldapadd to populate the database..."
99 $LDAPADD -D "$METAMANAGERDN" -h $LOCALHOST -p $PORT2 -w $PASSWD < \
100 $LDIFMETA >> $TESTOUT 2>&1
102 if test $RC != 0 ; then
103 echo "ldapadd failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
108 echo "Starting slapd on TCP/IP port $PORT3..."
109 . $CONFFILTER $BACKEND $MONITORDB < $METACONF > $CONF3
110 $SLAPD -f $CONF3 -h $URI3 -d $LVL $TIMING > $LOG3 2>&1 &
112 if test $WAIT != 0 ; then
116 KILLPIDS="$KILLPIDS $PID"
120 echo "Using ldapsearch to check that slapd is running..."
121 for i in 0 1 2 3 4 5; do
122 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT3 \
123 'objectclass=*' > /dev/null 2>&1
125 if test $RC = 0 ; then
128 echo "Waiting 5 seconds for slapd to start..."
131 if test $RC != 0 ; then
132 echo "ldapsearch failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 cat /dev/null > $SEARCHOUT
139 BASEDN="o=Example,c=US"
140 echo "Searching base=\"$BASEDN\"..."
141 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
142 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
144 #if test $RC != 0 ; then
145 # echo "Search failed ($RC)!"
146 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
154 test $KILLSERVERS != no && kill -HUP $KILLPIDS
158 echo "Search failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 # Do some modifications
168 BASEDN="o=Example,c=US"
169 echo "Modifying database \"$BASEDN\"..."
170 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT3 -w $PASSWD \
171 -M >> $TESTOUT 2>&1 << EOMODS
172 # These operations (updates with objectClass mapping) triggered ITS#3499
173 dn: cn=Added Group,ou=Groups,$BASEDN
175 objectClass: groupOfNames
176 objectClass: uidObject
178 member: cn=Added Group,ou=Groups,$BASEDN
181 dn: cn=Another Added Group,ou=Groups,$BASEDN
183 objectClass: groupOfNames
184 cn: Another Added Group
185 member: cn=Added Group,ou=Groups,$BASEDN
186 member: cn=Another Added Group,ou=Groups,$BASEDN
188 dn: cn=Another Added Group,ou=Groups,$BASEDN
191 objectClass: uidObject
197 dn: cn=Added Group,ou=Groups,$BASEDN
200 objectClass: uidObject
208 description: added to "ou=Meta,$BASEDN"
211 dn: ou=Who's going to handle this?,$BASEDN
213 objectClass: organizationalUnit
214 ou: Who's going to handle this?
216 description: will be deleted
218 dn: ou=Same as above,$BASEDN
220 objectClass: organizationalUnit
222 description: added right after "Who's going to handle this?"
223 description: will be preserved
225 dn: ou=Who's going to handle this?,$BASEDN
228 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
230 objectClass: organizationalUnit
231 ou: Who's going to handle this?
233 description: will be deleted
235 dn: ou=Same as above,ou=Meta,$BASEDN
237 objectClass: organizationalUnit
239 description: added right after "Who's going to handle this?"
240 description: will be preserved
242 dn: cn=Added User,ou=Same as above,ou=Meta,$BASEDN
244 objectClass: inetOrgPerson
249 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
254 #if test $RC != 0 ; then
255 # echo "Modify failed ($RC)!"
256 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
263 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Modify failed ($RC)!"
269 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 echo "Searching base=\"$BASEDN\"..."
275 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
276 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
278 #if test $RC != 0 ; then
279 # echo "Search failed ($RC)!"
280 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
287 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
292 echo "Search failed ($RC)!"
293 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 BASEDN="o=Example,c=US"
299 echo " base=\"$BASEDN\"..."
300 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
301 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" -M "$FILTER" '*' ref \
304 #if test $RC != 0 ; then
305 # echo "Search failed ($RC)!"
306 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
313 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
314 test $KILLSERVERS != no && kill -HUP $KILLPIDS
318 echo "Search failed ($RC)!"
319 test $KILLSERVERS != no && kill -HUP $KILLPIDS
324 BASEDN="o=Example,c=US"
325 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
326 echo "Searching filter=\"$FILTER\""
327 echo " attrs=\"seeAlso\""
328 echo " base=\"$BASEDN\"..."
329 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
330 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
331 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
332 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" seeAlso \
335 #if test $RC != 0 ; then
336 # echo "Search failed ($RC)!"
337 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
344 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
345 test $KILLSERVERS != no && kill -HUP $KILLPIDS
349 echo "Search failed ($RC)!"
350 test $KILLSERVERS != no && kill -HUP $KILLPIDS
355 FILTER="(uid=example)"
356 echo "Searching filter=\"$FILTER\""
357 echo " attrs=\"uid\""
358 echo " base=\"$BASEDN\"..."
359 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
360 echo "# attrs=\"uid\"" >> $SEARCHOUT
361 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
362 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" uid \
365 #if test $RC != 0 ; then
366 # echo "Search failed ($RC)!"
367 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
374 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
375 test $KILLSERVERS != no && kill -HUP $KILLPIDS
379 echo "Search failed ($RC)!"
380 test $KILLSERVERS != no && kill -HUP $KILLPIDS
385 FILTER="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
386 echo "Searching filter=\"$FILTER\""
387 echo " attrs=\"member\""
388 echo " base=\"$BASEDN\"..."
389 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
390 echo "# attrs=\"member\"" >> $SEARCHOUT
391 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
392 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" member \
395 #if test $RC != 0 ; then
396 # echo "Search failed ($RC)!"
397 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
404 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
405 test $KILLSERVERS != no && kill -HUP $KILLPIDS
409 echo "Search failed ($RC)!"
410 test $KILLSERVERS != no && kill -HUP $KILLPIDS
415 echo "Filtering ldapsearch results..."
416 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
417 echo "Filtering original ldif used to create database..."
418 . $LDIFFILTER < $METAOUT > $LDIFFLT
419 echo "Comparing filter output..."
420 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
422 if test $? != 0 ; then
423 echo "comparison failed - meta search/modification didn't succeed"
424 test $KILLSERVERS != no && kill -HUP $KILLPIDS
428 BASEDN="o=Example,c=US"
429 echo "Changing password to database \"$BASEDN\"..."
430 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
431 -s $PASSWD "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
434 #if test $RC != 0 ; then
435 # echo "Passwd ExOp failed ($RC)!"
436 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
443 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
444 test $KILLSERVERS != no && kill -HUP $KILLPIDS
448 echo "Passwd ExOp failed ($RC)!"
449 test $KILLSERVERS != no && kill -HUP $KILLPIDS
454 echo "Binding with newly changed password to database \"$BASEDN\"..."
455 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
456 -D "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
457 -w $PASSWD >> $TESTOUT 2>&1
459 #if test $RC != 0 ; then
460 # echo "WhoAmI failed ($RC)!"
461 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
468 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
471 echo "WhoAmI failed ($RC)!"
472 test $KILLSERVERS != no && kill -HUP $KILLPIDS
477 echo "Binding as newly added user to database \"$BASEDN\"..."
478 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
479 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
480 -w $PASSWD >> $TESTOUT 2>&1
482 #if test $RC != 0 ; then
483 # echo "WhoAmI failed ($RC)!"
484 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
491 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
494 echo "WhoAmI failed ($RC)!"
495 test $KILLSERVERS != no && kill -HUP $KILLPIDS
500 echo "Changing password to database \"$BASEDN\"..."
501 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
502 -s meta "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
505 #if test $RC != 0 ; then
506 # echo "Passwd ExOp failed ($RC)!"
507 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
514 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
515 test $KILLSERVERS != no && kill -HUP $KILLPIDS
519 echo "Passwd ExOp failed ($RC)!"
520 test $KILLSERVERS != no && kill -HUP $KILLPIDS
525 echo "Binding with newly changed password to database \"$BASEDN\"..."
526 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
527 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
528 -w meta >> $TESTOUT 2>&1
530 #if test $RC != 0 ; then
531 # echo "WhoAmI failed ($RC)!"
532 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
539 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
542 echo "WhoAmI failed ($RC)!"
543 test $KILLSERVERS != no && kill -HUP $KILLPIDS
548 echo "Comparing to database \"$BASEDN\"..."
549 $LDAPCOMPARE -h $LOCALHOST -p $PORT3 \
550 "cn=Another Added Group,ou=Groups,$BASEDN" \
551 "member:cn=Added Group,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
553 #if test $RC != 6 ; then
554 # echo "Compare failed ($RC)!"
555 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
562 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
565 echo "Compare failed ($RC)!"
566 test $KILLSERVERS != no && kill -HUP $KILLPIDS
571 test $KILLSERVERS != no && kill -HUP $KILLPIDS
573 echo ">>>>> Test succeeded"