2 # $OpenLDAP: pkg/ldap/tests/scripts/relay,v 1.13.2.5 2008/02/11 23:52:49 quanah Exp $
3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2008 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 "Using $RELAY backend..."
19 echo "Starting slapd on TCP/IP port $PORT1..."
20 echo "======== Starting slapd with $RELAY backend ========" >> $LOG1
21 .
$CONFFILTER $BACKEND $MONITORDB < $RELAYCONF > $CONF1
22 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING >> $LOG1 2>&1 &
24 if test $WAIT != 0 ; then
32 echo "Using ldapsearch to check that slapd is running..."
33 for i
in 0 1 2 3 4 5; do
34 $LDAPSEARCH -s base
-b "$MONITOR" -h $LOCALHOST -p $PORT1 \
35 'objectclass=*' > /dev
/null
2>&1
37 if test $RC = 0 ; then
40 echo "Waiting 5 seconds for slapd to start..."
43 if test $RC != 0 ; then
44 echo "ldapsearch failed ($RC)!"
45 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
49 echo "Using ldapadd to populate the database..."
50 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
51 $LDIFORDERED > $TESTOUT 2>&1
53 if test $RC != 0 ; then
54 echo "ldapadd failed ($RC)!"
55 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
59 cat /dev
/null
> $SEARCHOUT
61 BASEDN
="dc=example,dc=com"
62 echo "Searching base=\"$BASEDN\"..."
63 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
64 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
66 if test $RC != 0 ; then
67 echo "Search failed ($RC)!"
68 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
72 BASEDN
="o=Example,c=US"
73 echo "Searching base=\"$BASEDN\"..."
74 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
75 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
77 if test $RC != 0 ; then
78 echo "Search failed ($RC)!"
79 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
83 BASEDN
="o=Esempio,c=IT"
84 echo "Searching base=\"$BASEDN\"..."
85 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
86 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
88 if test $RC != 0 ; then
89 echo "Search failed ($RC)!"
90 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
94 BASEDN
="o=Beispiel,c=DE"
95 echo "Searching base=\"$BASEDN\"..."
96 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
97 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
99 if test $RC != 0 ; then
100 echo "Search failed ($RC)!"
101 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
106 # Do some modifications
109 BASEDN
="o=Beispiel,c=DE"
110 echo "Modifying database \"$BASEDN\"..."
111 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
112 -M >> $TESTOUT 2>&1 << EOMODS
113 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
115 objectClass: OpenLDAPperson
119 seealso: cn=All Staff,ou=Groups,$BASEDN
120 homephone: +49 1234567890
122 mail: auser@mail.alumni.example.com
123 telephonenumber: +49 1234-567-890
124 description: Just added in o=Beispiel,c=DE naming context
126 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
129 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
132 description: Just added self to seeAlso in $BASEDN virtual naming context
135 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
138 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
140 newrdn: cn=John P. Doe
143 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
145 newrdn: cn=Jane Q. Doe
147 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
149 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
152 cn: Jane Qissapaolo Doe
154 # This operation (delete of DN-valued attribute) triggered ITS#3498
158 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
161 seeAlso: cn=All Staff,ou=Groups,$BASEDN
164 dn: ou=Referrals,$BASEDN
166 objectclass: referral
167 objectclass: extensibleObject
169 ref: ldap://localhost.localdomain/ou=Referrals,$BASEDN
170 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,$BASEDN
172 dn: ou=Referrals,$BASEDN
175 ref: ldap://localhost:9012/ou=Referrals,$BASEDN
178 description: ...and modified as ldap://localhost:9012/ou=Referrals,$BASEDN
183 if test $RC != 0 ; then
184 echo "Modify failed ($RC)!"
185 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
189 BASEDN
="o=Example,c=US"
190 echo "Modifying database \"$BASEDN\"..."
191 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
192 -M >> $TESTOUT 2>&1 << EOMODS
193 # These operations (updates with objectClass mapping) triggered ITS#3499
194 dn: cn=Added Group,ou=Groups,$BASEDN
196 objectClass: groupOfNames
197 objectClass: uidObject
199 member: cn=Added Group,ou=Groups,$BASEDN
202 dn: cn=Another Added Group,ou=Groups,$BASEDN
204 objectClass: groupOfNames
205 cn: Another Added Group
206 member: cn=Added Group,ou=Groups,$BASEDN
207 member: cn=Another Added Group,ou=Groups,$BASEDN
209 dn: cn=Another Added Group,ou=Groups,$BASEDN
212 objectClass: uidObject
218 dn: cn=Added Group,ou=Groups,$BASEDN
221 objectClass: uidObject
228 if test $RC != 0 ; then
229 echo "Modify failed ($RC)!"
230 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
234 echo "Searching base=\"$BASEDN\"..."
235 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
236 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
238 if test $RC != 0 ; then
239 echo "Search failed ($RC)!"
240 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
244 BASEDN
="o=Esempio,c=IT"
245 echo "Searching base=\"$BASEDN\"..."
246 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
247 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
249 if test $RC != 0 ; then
250 echo "Search failed ($RC)!"
251 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
255 FILTER
="(objectClass=referral)"
256 echo "Searching filter=\"$FILTER\""
257 echo " attrs=\"'*' ref\""
258 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
259 echo "# attrs=\"'*' ref\"" >> $SEARCHOUT
261 BASEDN
="dc=example,dc=com"
262 echo " base=\"$BASEDN\"..."
263 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
264 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
267 if test $RC != 0 ; then
268 echo "Search failed ($RC)!"
269 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
273 BASEDN
="o=Example,c=US"
274 echo " base=\"$BASEDN\"..."
275 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
276 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
279 if test $RC != 0 ; then
280 echo "Search failed ($RC)!"
281 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
285 BASEDN
="o=Esempio,c=IT"
286 echo " base=\"$BASEDN\"..."
287 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
288 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" '*' ref \
291 if test $RC != 0 ; then
292 echo "Search failed ($RC)!"
293 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
297 BASEDN
="o=Example,c=US"
298 FILTER
="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
299 echo "Searching filter=\"$FILTER\""
300 echo " attrs=\"seeAlso\""
301 echo " base=\"$BASEDN\"..."
302 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
303 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
304 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
305 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
308 if test $RC != 0 ; then
309 echo "Search failed ($RC)!"
310 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
314 FILTER
="(uid=example)"
315 echo "Searching filter=\"$FILTER\""
316 echo " attrs=\"uid\""
317 echo " base=\"$BASEDN\"..."
318 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
319 echo "# attrs=\"uid\"" >> $SEARCHOUT
320 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
321 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" uid \
324 if test $RC != 0 ; then
325 echo "Search failed ($RC)!"
326 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
330 FILTER
="(member=cn=Another Added Group,ou=Groups,$BASEDN)"
331 echo "Searching filter=\"$FILTER\""
332 echo " attrs=\"member\""
333 echo " base=\"$BASEDN\"..."
334 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
335 echo "# attrs=\"member\"" >> $SEARCHOUT
336 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
337 $LDAPSEARCH -S '' -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" member \
340 if test $RC != 0 ; then
341 echo "Search failed ($RC)!"
342 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
346 echo "Filtering ldapsearch results..."
347 .
$LDIFFILTER < $SEARCHOUT > $SEARCHFLT
348 echo "Filtering original ldif used to create database..."
349 .
$LDIFFILTER < $RELAYOUT > $LDIFFLT
350 echo "Comparing filter output..."
351 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
353 if test $?
!= 0 ; then
354 echo "comparison failed - relay search/modification didn't succeed"
355 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
359 BASEDN
="o=Example,c=US"
360 echo "Changing password to database \"$BASEDN\"..."
361 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
362 -s $PASSWD "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
365 if test $RC != 0 ; then
366 echo "Passwd ExOp failed ($RC)!"
367 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
371 BASEDN
="o=Beispiel,c=DE"
372 echo "Binding with newly changed password to database \"$BASEDN\"..."
373 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
374 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
375 -w $PASSWD >> $TESTOUT 2>&1
377 if test $RC != 0 ; then
378 echo "WhoAmI failed ($RC)!"
379 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
383 BASEDN
="o=Esempio,c=IT"
384 echo "Comparing to database \"$BASEDN\"..."
385 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
386 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
387 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
389 if test $RC != 6 ; then
390 echo "Compare failed ($RC)!"
391 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS
395 test $KILLSERVERS != no
&& kill -HUP $KILLPIDS