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
21 if test $BACKLDAP = ldapno ; then
22 echo "ldap backend not available, test skipped"
28 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 . $CONFFILTER $BACKEND $MONITORDB < $METACONF1 > $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 < $GLUELDAPCONF > $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
164 # ITS#4195: spurious matchedDN when the search scopes the main target,
165 # and the searchBase is not present, so that target returns noSuchObject
166 BASEDN="ou=Meta,o=Example,c=US"
167 echo "Searching base=\"$BASEDN\"..."
168 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
169 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
171 #if test $RC != 0 ; then
172 # echo "Search failed ($RC)!"
173 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
181 test $KILLSERVERS != no && kill -HUP $KILLPIDS
185 echo "Search failed ($RC)!"
186 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 # Do some modifications
195 BASEDN="o=Example,c=US"
196 echo "Modifying database \"$BASEDN\"..."
197 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT3 -w $PASSWD \
198 -M >> $TESTOUT 2>&1 << EOMODS
199 # These operations (updates with objectClass mapping) triggered ITS#3499
200 dn: cn=Added Group,ou=Groups,$BASEDN
202 objectClass: groupOfNames
203 objectClass: uidObject
205 member: cn=Added Group,ou=Groups,$BASEDN
208 dn: cn=Another Added Group,ou=Groups,$BASEDN
210 objectClass: groupOfNames
211 cn: Another Added Group
212 member: cn=Added Group,ou=Groups,$BASEDN
213 member: cn=Another Added Group,ou=Groups,$BASEDN
215 dn: cn=Another Added Group,ou=Groups,$BASEDN
218 objectClass: uidObject
224 dn: cn=Added Group,ou=Groups,$BASEDN
227 objectClass: uidObject
235 description: added to "ou=Meta,$BASEDN"
238 dn: ou=Who's going to handle this?,$BASEDN
240 objectClass: organizationalUnit
241 ou: Who's going to handle this?
243 description: will be deleted
245 dn: ou=Same as above,$BASEDN
247 objectClass: organizationalUnit
249 description: added right after "Who's going to handle this?"
250 description: will be preserved
252 dn: ou=Who's going to handle this?,$BASEDN
255 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
257 objectClass: organizationalUnit
258 ou: Who's going to handle this?
260 description: will be deleted
262 dn: ou=Same as above,ou=Meta,$BASEDN
264 objectClass: organizationalUnit
266 description: added right after "Who's going to handle this?"
267 description: will be preserved
269 dn: cn=Added User,ou=Same as above,ou=Meta,$BASEDN
271 objectClass: inetOrgPerson
276 dn: ou=Who's going to handle this?,ou=Meta,$BASEDN
281 #if test $RC != 0 ; then
282 # echo "Modify failed ($RC)!"
283 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
291 test $KILLSERVERS != no && kill -HUP $KILLPIDS
295 echo "Modify failed ($RC)!"
296 test $KILLSERVERS != no && kill -HUP $KILLPIDS
301 echo "Searching base=\"$BASEDN\"..."
302 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
303 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" >> $SEARCHOUT 2>&1
305 #if test $RC != 0 ; then
306 # echo "Search failed ($RC)!"
307 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
314 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
315 test $KILLSERVERS != no && kill -HUP $KILLPIDS
319 echo "Search failed ($RC)!"
320 test $KILLSERVERS != no && kill -HUP $KILLPIDS
325 BASEDN="o=Example,c=US"
326 echo " base=\"$BASEDN\"..."
327 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
328 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" -M "$FILTER" '*' ref \
331 #if test $RC != 0 ; then
332 # echo "Search failed ($RC)!"
333 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
340 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
341 test $KILLSERVERS != no && kill -HUP $KILLPIDS
345 echo "Search failed ($RC)!"
346 test $KILLSERVERS != no && kill -HUP $KILLPIDS
351 BASEDN="o=Example,c=US"
352 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
353 echo "Searching filter=\"$FILTER\""
354 echo " attrs=\"seeAlso\""
355 echo " base=\"$BASEDN\"..."
356 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
357 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
358 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
359 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" seeAlso \
362 #if test $RC != 0 ; then
363 # echo "Search failed ($RC)!"
364 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
371 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
372 test $KILLSERVERS != no && kill -HUP $KILLPIDS
376 echo "Search failed ($RC)!"
377 test $KILLSERVERS != no && kill -HUP $KILLPIDS
382 FILTER="(uid=example)"
383 echo "Searching filter=\"$FILTER\""
384 echo " attrs=\"uid\""
385 echo " base=\"$BASEDN\"..."
386 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
387 echo "# attrs=\"uid\"" >> $SEARCHOUT
388 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
389 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" uid \
392 #if test $RC != 0 ; then
393 # echo "Search failed ($RC)!"
394 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
401 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
402 test $KILLSERVERS != no && kill -HUP $KILLPIDS
406 echo "Search failed ($RC)!"
407 test $KILLSERVERS != no && kill -HUP $KILLPIDS
412 FILTER="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
413 echo "Searching filter=\"$FILTER\""
414 echo " attrs=\"member\""
415 echo " base=\"$BASEDN\"..."
416 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
417 echo "# attrs=\"member\"" >> $SEARCHOUT
418 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
419 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -b "$BASEDN" "$FILTER" member \
422 #if test $RC != 0 ; then
423 # echo "Search failed ($RC)!"
424 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
431 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
432 test $KILLSERVERS != no && kill -HUP $KILLPIDS
436 echo "Search failed ($RC)!"
437 test $KILLSERVERS != no && kill -HUP $KILLPIDS
442 echo "Waiting 10 seconds for cached connections to timeout..."
445 echo "Searching with a timed out connection..."
446 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
447 echo "# attrs=\"member\"" >> $SEARCHOUT
448 echo "# base=\"$BASEDN\"" >> $SEARCHOUT
449 echo "# with a timed out connection..." >> $SEARCHOUT
450 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
451 -b "$BASEDN" "$FILTER" member \
454 #if test $RC != 0 ; then
455 # echo "Search failed ($RC)!"
456 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
463 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
464 test $KILLSERVERS != no && kill -HUP $KILLPIDS
468 echo "Search failed ($RC)!"
469 test $KILLSERVERS != no && kill -HUP $KILLPIDS
474 # NOTE: cannot send to $SEARCHOUT because the returned entries
475 # are not predictable...
476 echo "Checking server-enforced size limit..."
477 echo "# Checking server-enforced size limit..." >> $SEARCHOUT
478 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 \
479 -D "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" -w bjorn \
480 -b "$BASEDN" "(objectClass=*)" 1.1 \
485 echo "Search should have failed ($RC)!"
486 test $KILLSERVERS != no && kill -HUP $KILLPIDS
492 echo "Search failed ($RC)!"
493 test $KILLSERVERS != no && kill -HUP $KILLPIDS
498 # NOTE: cannot send to $SEARCHOUT because the returned entries
499 # are not predictable...
500 echo "Checking client-requested size limit..."
501 echo "# Checking client-requested size limit..." >> $SEARCHOUT
502 $LDAPSEARCH -S "" -h $LOCALHOST -p $PORT3 \
503 -D "cn=Bjorn Jensen,ou=Information Technology Division,ou=People,$BASEDN" -w bjorn \
504 -b "$BASEDN" -z 2 "(objectClass=*)" 1.1 \
509 echo "Search should have failed ($RC)!"
510 test $KILLSERVERS != no && kill -HUP $KILLPIDS
516 echo "Search failed ($RC)!"
517 test $KILLSERVERS != no && kill -HUP $KILLPIDS
522 echo "Filtering ldapsearch results..."
523 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
524 echo "Filtering original ldif used to create database..."
525 . $LDIFFILTER < $METAOUT > $LDIFFLT
526 echo "Comparing filter output..."
527 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
529 if test $? != 0 ; then
530 echo "comparison failed - meta search/modification didn't succeed"
531 test $KILLSERVERS != no && kill -HUP $KILLPIDS
535 # ITS#4458 needs patch to slapo-rwm for global rewriting of passwd_exop
536 BASEDN="o=Example,c=US"
537 echo "Changing password to database \"$BASEDN\"..."
538 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
539 -s $PASSWD "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
542 #if test $RC != 0 ; then
543 # echo "Passwd ExOp failed ($RC)!"
544 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
551 # echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
552 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
557 echo "Passwd ExOp failed ($RC)! ITS#4458?"
560 echo "Passwd ExOp failed ($RC)!"
561 test $KILLSERVERS != no && kill -HUP $KILLPIDS
566 if test $RC = 0 ; then
567 echo "Binding with newly changed password to database \"$BASEDN\"..."
568 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
569 -D "cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN" \
570 -w $PASSWD >> $TESTOUT 2>&1
572 #if test $RC != 0 ; then
573 # echo "WhoAmI failed ($RC)!"
574 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
581 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
584 echo "WhoAmI failed ($RC)!"
585 test $KILLSERVERS != no && kill -HUP $KILLPIDS
591 echo "Binding as newly added user to database \"$BASEDN\"..."
592 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
593 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
594 -w $PASSWD >> $TESTOUT 2>&1
596 #if test $RC != 0 ; then
597 # echo "WhoAmI failed ($RC)!"
598 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
605 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
608 echo "WhoAmI failed ($RC)!"
609 test $KILLSERVERS != no && kill -HUP $KILLPIDS
614 echo "Changing password to database \"$BASEDN\"..."
615 $LDAPPASSWD -h $LOCALHOST -p $PORT3 -D "cn=Manager,$BASEDN" -w $PASSWD \
616 -s meta "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
619 #if test $RC != 0 ; then
620 # echo "Passwd ExOp failed ($RC)!"
621 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
628 # echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
629 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
634 echo "Passwd ExOp failed ($RC)! ITS#4458?"
637 echo "Passwd ExOp failed ($RC)!"
638 test $KILLSERVERS != no && kill -HUP $KILLPIDS
643 if test $RC = 0 ; then
644 echo "Binding with newly changed password to database \"$BASEDN\"..."
645 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
646 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
647 -w meta >> $TESTOUT 2>&1
649 #if test $RC != 0 ; then
650 # echo "WhoAmI failed ($RC)!"
651 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
658 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
661 echo "WhoAmI failed ($RC)!"
662 test $KILLSERVERS != no && kill -HUP $KILLPIDS
668 echo "Binding with incorrect password to database \"$BASEDN\"..."
669 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
670 -D "cn=Added User,ou=Same as above,ou=Meta,$BASEDN" \
671 -w bogus >> $TESTOUT 2>&1
673 #if test $RC != 0 ; then
674 # echo "WhoAmI failed ($RC)!"
675 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
680 echo "WhoAmI should have failed ($RC)!"
681 test $KILLSERVERS != no && kill -HUP $KILLPIDS
685 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
691 echo "Binding with non-existing user to database \"$BASEDN\"..."
692 $LDAPWHOAMI -h $LOCALHOST -p $PORT3 \
693 -D "cn=Non-existing User,ou=Same as above,ou=Meta,$BASEDN" \
694 -w bogus >> $TESTOUT 2>&1
696 #if test $RC != 0 ; then
697 # echo "WhoAmI failed ($RC)!"
698 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
703 echo "WhoAmI should have failed ($RC)!"
704 test $KILLSERVERS != no && kill -HUP $KILLPIDS
708 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
714 echo "Comparing to database \"$BASEDN\"..."
715 $LDAPCOMPARE -h $LOCALHOST -p $PORT3 \
716 "cn=Another Added Group,ou=Groups,$BASEDN" \
717 "member:cn=Added Group,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
719 #if test $RC != 6 ; then
720 # echo "Compare failed ($RC)!"
721 # test $KILLSERVERS != no && kill -HUP $KILLPIDS
728 echo "### Hit LDAP_BUSY problem; you may want to re-run the test"
731 echo "Compare failed ($RC)!"
732 test $KILLSERVERS != no && kill -HUP $KILLPIDS
737 test $KILLSERVERS != no && kill -HUP $KILLPIDS
739 echo ">>>>> Test succeeded"
741 test $KILLSERVERS != no && wait