3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 $RWM = rwmno ; then
20 echo "Rewrite/remap overlay not available, test skipped"
24 if test $BACKLDAP = "ldapno" ; then
25 echo "LDAP backend not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Starting slapd on TCP/IP port $PORT1..."
32 . $CONFFILTER $BACKEND $MONITORDB < $PROXYMASSAGECONF > $CONF1
33 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
35 if test $WAIT != 0 ; then
41 echo "Using ldapsearch to check that slapd is running..."
42 for i in 0 1 2 3 4 5; do
43 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
44 'objectclass=*' > /dev/null 2>&1
46 if test $RC = 0 ; then
49 echo "Waiting 5 seconds for slapd to start..."
52 if test $RC != 0 ; then
53 echo "ldapsearch failed $(RC)!"
54 test $KILLSERVERS != no && kill -HUP $KILLPIDS
58 echo "Using ldapadd to populate the database..."
59 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
60 $LDIFORDERED > $TESTOUT 2>&1
62 if test $RC != 0 ; then
63 echo "ldapadd failed ($RC)!"
64 test $KILLSERVERS != no && kill -HUP $KILLPIDS
68 cat /dev/null > $SEARCHOUT
70 BASEDN="dc=example,dc=com"
71 echo "searching base=\"$BASEDN\"..."
72 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
73 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
75 if test $RC != 0 ; then
76 echo "Search failed ($RC)!"
77 test $KILLSERVERS != no && kill -HUP $KILLPIDS
81 BASEDN="o=Example,c=US"
82 echo "searching base=\"$BASEDN\"..."
83 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
84 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
86 if test $RC != 0 ; then
87 echo "Search failed ($RC)!"
88 test $KILLSERVERS != no && kill -HUP $KILLPIDS
92 BASEDN="o=Esempio,c=IT"
93 echo "searching base=\"$BASEDN\"..."
94 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
95 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
97 if test $RC != 0 ; then
98 echo "Search failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 BASEDN="o=Beispiel,c=DE"
104 echo "searching base=\"$BASEDN\"..."
105 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
106 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
108 if test $RC != 0 ; then
109 echo "Search failed ($RC)!"
110 test $KILLSERVERS != no && kill -HUP $KILLPIDS
115 # Do some modifications
118 BASEDN="o=Beispiel,c=DE"
119 echo "modifying database \"$BASEDN\"..."
120 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
121 -e manageDSAit >> $TESTOUT 2>&1 << EOMODS
122 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
124 objectClass: OpenLDAPperson
128 seealso: cn=All Staff,ou=Groups,$BASEDN
129 homephone: +49 1234567890
131 mail: auser@mail.alumni.example.com
132 telephonenumber: +49 1234-567-890
133 description: Just added in o=Beispiel,c=DE naming context
135 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
138 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
141 description: Just added self to seeAlso in $BASEDN virtual naming context
144 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
147 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
149 newrdn: cn=John P. Doe
152 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
154 newrdn: cn=Jane Q. Doe
156 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
158 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
161 cn: Jane Qissapaolo Doe
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://ldap.example.com:389/ou=Referrals,${BASEDN}
178 description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,${BASEDN}
182 if test $RC != 0 ; then
183 echo "Modify failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 echo "searching base=\"$BASEDN\"..."
189 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
190 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
192 if test $RC != 0 ; then
193 echo "Search failed ($RC)!"
194 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 BASEDN="o=Esempio,c=IT"
199 echo "searching base=\"$BASEDN\"..."
200 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
201 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
203 if test $RC != 0 ; then
204 echo "Search failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 FILTER="(objectClass=referral)"
210 echo "searching filter=\"$FILTER\""
211 echo " attrs=\"'*' ref\""
212 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
213 echo "# attrs=\"'*' ref\"" >> $SEARCHOUT
215 BASEDN="dc=example,dc=com"
216 echo " base=\"$BASEDN\"..."
217 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
218 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
219 -e manageDSAit >> $SEARCHOUT 2>&1
221 if test $RC != 0 ; then
222 echo "Search failed ($RC)!"
223 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 BASEDN="o=Example,c=US"
228 echo " base=\"$BASEDN\"..."
229 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
230 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
231 -e manageDSAit >> $SEARCHOUT 2>&1
233 if test $RC != 0 ; then
234 echo "Search failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 BASEDN="o=Esempio,c=IT"
240 echo " base=\"$BASEDN\"..."
241 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
242 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
243 -e manageDSAit >> $SEARCHOUT 2>&1
245 if test $RC != 0 ; then
246 echo "Search failed ($RC)!"
247 test $KILLSERVERS != no && kill -HUP $KILLPIDS
251 BASEDN="o=Example,c=US"
252 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
253 echo "searching filter=\"$FILTER\""
254 echo " attrs=\"seeAlso\""
255 echo " base=\"$BASEDN\"..."
256 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
257 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
258 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
259 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
262 if test $RC != 0 ; then
263 echo "Search failed ($RC)!"
264 test $KILLSERVERS != no && kill -HUP $KILLPIDS
268 echo "Filtering ldapsearch results..."
269 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
270 echo "Filtering original ldif used to create database..."
271 . $LDIFFILTER < $PROXYMASSAGEOUT > $LDIFFLT
272 echo "Comparing filter output..."
273 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
275 if test $? != 0 ; then
276 echo "comparison failed - back-ldap search/modification didn't succeed"
277 test $KILLSERVERS != no && kill -HUP $KILLPIDS
281 BASEDN="o=Example,c=US"
282 echo "changing password to database \"$BASEDN\"..."
283 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
284 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
285 -s $PASSWD >> $TESTOUT 2>&1
287 if test $RC != 0 ; then
288 echo "Passwd ExOp failed ($RC)!"
289 test $KILLSERVERS != no && kill -HUP $KILLPIDS
293 BASEDN="o=Beispiel,c=DE"
294 echo "binding with newly changed password to database \"$BASEDN\"..."
295 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
296 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
297 -w $PASSWD >> $TESTOUT 2>&1
299 if test $RC != 0 ; then
300 echo "WhoAmI failed ($RC)!"
301 test $KILLSERVERS != no && kill -HUP $KILLPIDS
305 BASEDN="o=Esempio,c=IT"
306 echo "comparing to database \"$BASEDN\"..."
307 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
308 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
309 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
311 if test $RC != 6 ; then
312 echo "Compare failed ($RC)!"
313 test $KILLSERVERS != no && kill -HUP $KILLPIDS
317 test $KILLSERVERS != no && kill -HUP $KILLPIDS
319 echo ">>>>> Test succeeded"