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 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 -M >> $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: ou=Referrals,$BASEDN
160 objectclass: referral
161 objectclass: extensibleObject
163 ref: ldap://localhost.localdomain/ou=Referrals,$BASEDN
164 description: Just added as ldap://localhost.localdomain/ou=Referrals,$BASEDN
166 dn: ou=Referrals,$BASEDN
169 ref: ldap://ldap.example.com/ou=Referrals,$BASEDN
172 description: ...and modified as ldap://ldap.example.com/ou=Referrals,$BASEDN
177 if test $RC != 0 ; then
178 echo "Modify failed ($RC)!"
179 test $KILLSERVERS != no && kill -HUP $KILLPIDS
183 echo "searching base=\"$BASEDN\"..."
184 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
185 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
187 if test $RC != 0 ; then
188 echo "Search failed ($RC)!"
189 test $KILLSERVERS != no && kill -HUP $KILLPIDS
193 BASEDN="o=Esempio,c=IT"
194 echo "searching base=\"$BASEDN\"..."
195 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
196 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
198 if test $RC != 0 ; then
199 echo "Search failed ($RC)!"
200 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 FILTER="(objectClass=referral)"
205 echo "searching filter=\"$FILTER\""
206 echo " attrs=\"'*' ref\""
208 BASEDN="dc=example,dc=com"
209 echo " base=\"$BASEDN\"..."
210 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
211 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
214 if test $RC != 0 ; then
215 echo "Search failed ($RC)!"
216 test $KILLSERVERS != no && kill -HUP $KILLPIDS
220 BASEDN="o=Example,c=US"
221 echo " base=\"$BASEDN\"..."
222 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
223 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
226 if test $RC != 0 ; then
227 echo "Search failed ($RC)!"
228 test $KILLSERVERS != no && kill -HUP $KILLPIDS
232 BASEDN="o=Esempio,c=IT"
233 echo " base=\"$BASEDN\"..."
234 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
235 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
238 if test $RC != 0 ; then
239 echo "Search failed ($RC)!"
240 test $KILLSERVERS != no && kill -HUP $KILLPIDS
244 BASEDN="o=Example,c=US"
245 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
246 echo "searching filter=\"$FILTER\""
247 echo " attrs=\"seeAlso\""
248 echo " base=\"$BASEDN\"..."
249 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
250 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
251 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
252 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
255 if test $RC != 0 ; then
256 echo "Search failed ($RC)!"
257 test $KILLSERVERS != no && kill -HUP $KILLPIDS
261 echo "Filtering ldapsearch results..."
262 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
263 echo "Filtering original ldif used to create database..."
264 . $LDIFFILTER < $RELAYOUT > $LDIFFLT
265 echo "Comparing filter output..."
266 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
268 if test $? != 0 ; then
269 echo "comparison failed - relay search/modification didn't succeed"
270 test $KILLSERVERS != no && kill -HUP $KILLPIDS
274 BASEDN="o=Example,c=US"
275 echo "changing password to database \"$BASEDN\"..."
276 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
277 -s $PASSWD "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
280 if test $RC != 0 ; then
281 echo "Passwd ExOp failed ($RC)!"
282 test $KILLSERVERS != no && kill -HUP $KILLPIDS
286 BASEDN="o=Beispiel,c=DE"
287 echo "binding with newly changed password to database \"$BASEDN\"..."
288 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
289 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
290 -w $PASSWD >> $TESTOUT 2>&1
292 if test $RC != 0 ; then
293 echo "WhoAmI failed ($RC)!"
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
298 BASEDN="o=Esempio,c=IT"
299 echo "comparing to database \"$BASEDN\"..."
300 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
301 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
302 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
304 if test $RC != 6 ; then
305 echo "Compare failed ($RC)!"
306 test $KILLSERVERS != no && kill -HUP $KILLPIDS
310 test $KILLSERVERS != no && kill -HUP $KILLPIDS
312 echo ">>>>> Test succeeded"