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 $BACKRELAY = relayno ; then
20 echo "relay backend not available, test skipped"
24 if test $RWM = rwmno ; then
25 echo "Rewrite/remap overlay not available, test skipped"
29 mkdir -p $TESTDIR $DBDIR1
31 echo "Starting slapd on TCP/IP port $PORT1..."
32 . $CONFFILTER $BACKEND $MONITORDB < $RWMCONF > $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 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
74 if test $RC != 0 ; then
75 echo "Search failed ($RC)!"
76 test $KILLSERVERS != no && kill -HUP $KILLPIDS
80 BASEDN="o=Example,c=US"
81 echo "searching base=\"$BASEDN\"..."
82 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
84 if test $RC != 0 ; then
85 echo "Search failed ($RC)!"
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
90 BASEDN="o=Esempio,c=IT"
91 echo "searching base=\"$BASEDN\"..."
92 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
94 if test $RC != 0 ; then
95 echo "Search failed ($RC)!"
96 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 BASEDN="o=Beispiel,c=DE"
101 echo "searching base=\"$BASEDN\"..."
102 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
104 if test $RC != 0 ; then
105 echo "Search failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 # Do some modifications
114 BASEDN="o=Beispiel,c=DE"
115 echo "modifying database \"$BASEDN\"..."
116 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
117 -e manageDSAit >> $TESTOUT 2>&1 << EOMODS
118 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
120 objectClass: OpenLDAPperson
124 seealso: cn=All Staff,ou=Groups,$BASEDN
125 homephone: +49 1234567890
127 mail: auser@mail.alumni.example.com
128 telephonenumber: +49 1234-567-890
129 description: Just added in o=Beispiel,c=DE naming context
131 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
134 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
137 description: Just added self to seeAlso in $BASEDN virtual naming context
140 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
143 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
145 newrdn: cn=John P. Doe
148 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
150 newrdn: cn=Jane Q. Doe
152 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
154 dn: ou=Referrals,$BASEDN
156 objectclass: referral
157 objectclass: extensibleObject
159 ref: ldap://localhost.localdomain/ou=Referrals,$BASEDN
160 description: Just added as ldap://localhost.localdomain/ou=Referrals,$BASEDN
162 dn: ou=Referrals,$BASEDN
165 ref: ldap://ldap.example.com/ou=Referrals,$BASEDN
168 description: ...and modified as ldap://ldap.example.com/ou=Referrals,$BASEDN
172 if test $RC != 0 ; then
173 echo "Modify failed ($RC)!"
174 test $KILLSERVERS != no && kill -HUP $KILLPIDS
178 BASEDN="o=Esempio,c=IT"
179 echo "searching base=\"$BASEDN\"..."
180 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
182 if test $RC != 0 ; then
183 echo "Search failed ($RC)!"
184 test $KILLSERVERS != no && kill -HUP $KILLPIDS
188 FILTER="(objectClass=referral)"
189 echo "searching filter=\"$FILTER\""
190 echo " attrs=\"'*' ref\""
192 BASEDN="dc=example,dc=com"
193 echo " base=\"$BASEDN\"..."
194 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
195 -e manageDSAit >> $SEARCHOUT 2>&1
197 if test $RC != 0 ; then
198 echo "Search failed ($RC)!"
199 test $KILLSERVERS != no && kill -HUP $KILLPIDS
203 BASEDN="o=Example,c=US"
204 echo " base=\"$BASEDN\"..."
205 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
206 -e manageDSAit >> $SEARCHOUT 2>&1
208 if test $RC != 0 ; then
209 echo "Search failed ($RC)!"
210 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 BASEDN="o=Esempio,c=IT"
215 echo " base=\"$BASEDN\"..."
216 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" "*" ref \
217 -e manageDSAit >> $SEARCHOUT 2>&1
219 if test $RC != 0 ; then
220 echo "Search failed ($RC)!"
221 test $KILLSERVERS != no && kill -HUP $KILLPIDS
225 BASEDN="o=Example,c=US"
226 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
227 echo "searching filter=\"$FILTER\""
228 echo " attrs=\"seeAlso\""
229 echo " base=\"$BASEDN\"..."
230 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
233 if test $RC != 0 ; then
234 echo "Search failed ($RC)!"
235 test $KILLSERVERS != no && kill -HUP $KILLPIDS
239 echo "Filtering ldapsearch results..."
240 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
241 echo "Filtering original ldif used to create database..."
242 . $LDIFFILTER < $RELAYOUT > $LDIFFLT
243 echo "Comparing filter output..."
244 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
246 if test $? != 0 ; then
247 echo "comparison failed - relay search/modification didn't succeed"
248 test $KILLSERVERS != no && kill -HUP $KILLPIDS
252 BASEDN="o=Example,c=US"
253 echo "changing password to database \"$BASEDN\"..."
254 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
255 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
256 -s $PASSWD >> $TESTOUT 2>&1
258 if test $RC != 0 ; then
259 echo "Passwd ExOp failed ($RC)!"
260 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 BASEDN="o=Beispiel,c=DE"
265 echo "binding with newly changed password to database \"$BASEDN\"..."
266 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
267 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
268 -w $PASSWD >> $TESTOUT 2>&1
270 if test $RC != 0 ; then
271 echo "WhoAmI failed ($RC)!"
272 test $KILLSERVERS != no && kill -HUP $KILLPIDS
276 BASEDN="o=Esempio,c=IT"
277 echo "comparing to database \"$BASEDN\"..."
278 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
279 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
280 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
282 if test $RC != 6 ; then
283 echo "Compare failed ($RC)!"
284 test $KILLSERVERS != no && kill -HUP $KILLPIDS
288 test $KILLSERVERS != no && kill -HUP $KILLPIDS
290 echo ">>>>> Test succeeded"