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 "Testing virtual naming context mapping with $RELAY backend..."
19 echo "Starting slapd on TCP/IP port $PORT1..."
20 . $CONFFILTER $BACKEND $MONITORDB < $RWMCONF > $CONF1
21 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
23 if test $WAIT != 0 ; then
29 echo "Using ldapsearch to check that slapd is running..."
30 for i in 0 1 2 3 4 5; do
31 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
32 'objectclass=*' > /dev/null 2>&1
34 if test $RC = 0 ; then
37 echo "Waiting 5 seconds for slapd to start..."
40 if test $RC != 0 ; then
41 echo "ldapsearch failed $(RC)!"
42 test $KILLSERVERS != no && kill -HUP $KILLPIDS
46 echo "Using ldapadd to populate the database..."
47 $LDAPADD -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD < \
48 $LDIFORDERED > $TESTOUT 2>&1
50 if test $RC != 0 ; then
51 echo "ldapadd failed ($RC)!"
52 test $KILLSERVERS != no && kill -HUP $KILLPIDS
56 cat /dev/null > $SEARCHOUT
58 BASEDN="dc=example,dc=com"
59 echo "searching base=\"$BASEDN\"..."
60 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
61 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
63 if test $RC != 0 ; then
64 echo "Search failed ($RC)!"
65 test $KILLSERVERS != no && kill -HUP $KILLPIDS
69 BASEDN="o=Example,c=US"
70 echo "searching base=\"$BASEDN\"..."
71 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
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=Esempio,c=IT"
81 echo "searching base=\"$BASEDN\"..."
82 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
83 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
85 if test $RC != 0 ; then
86 echo "Search failed ($RC)!"
87 test $KILLSERVERS != no && kill -HUP $KILLPIDS
91 BASEDN="o=Beispiel,c=DE"
92 echo "searching base=\"$BASEDN\"..."
93 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
94 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
96 if test $RC != 0 ; then
97 echo "Search failed ($RC)!"
98 test $KILLSERVERS != no && kill -HUP $KILLPIDS
103 # Do some modifications
106 BASEDN="o=Beispiel,c=DE"
107 echo "modifying database \"$BASEDN\"..."
108 $LDAPMODIFY -v -D "cn=Manager,$BASEDN" -h $LOCALHOST -p $PORT1 -w $PASSWD \
109 -M >> $TESTOUT 2>&1 << EOMODS
110 dn: cn=Added User,ou=Alumni Association,ou=People,$BASEDN
112 objectClass: OpenLDAPperson
116 seealso: cn=All Staff,ou=Groups,$BASEDN
117 homephone: +49 1234567890
119 mail: auser@mail.alumni.example.com
120 telephonenumber: +49 1234-567-890
121 description: Just added in o=Beispiel,c=DE naming context
123 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
126 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
129 description: Just added self to seeAlso in $BASEDN virtual naming context
132 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
135 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
137 newrdn: cn=John P. Doe
140 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
142 newrdn: cn=Jane Q. Doe
144 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
146 dn: cn=Jane Q. Doe,ou=Information Technology Division,ou=People,$BASEDN
149 cn: Jane Qissapaolo Doe
152 dn: ou=Referrals,$BASEDN
154 objectclass: referral
155 objectclass: extensibleObject
157 ref: ldap://localhost.localdomain/ou=Referrals,$BASEDN
158 description: Just added as ldap://localhost.localdomain:389/ou=Referrals,$BASEDN
160 dn: ou=Referrals,$BASEDN
163 ref: ldap://ldap.example.com:389/ou=Referrals,$BASEDN
166 description: ...and modified as ldap://ldap.example.com:389/ou=Referrals,$BASEDN
171 if test $RC != 0 ; then
172 echo "Modify failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 echo "searching base=\"$BASEDN\"..."
178 echo "# searching base=\"$BASEDN\"..." >> $SEARCHOUT
179 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
181 if test $RC != 0 ; then
182 echo "Search failed ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 BASEDN="o=Esempio,c=IT"
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 FILTER="(objectClass=referral)"
199 echo "searching filter=\"$FILTER\""
200 echo " attrs=\"'*' ref\""
201 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
202 echo "# attrs=\"'*' ref\"" >> $SEARCHOUT
204 BASEDN="dc=example,dc=com"
205 echo " base=\"$BASEDN\"..."
206 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
207 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
210 if test $RC != 0 ; then
211 echo "Search failed ($RC)!"
212 test $KILLSERVERS != no && kill -HUP $KILLPIDS
216 BASEDN="o=Example,c=US"
217 echo " base=\"$BASEDN\"..."
218 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
219 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
222 if test $RC != 0 ; then
223 echo "Search failed ($RC)!"
224 test $KILLSERVERS != no && kill -HUP $KILLPIDS
228 BASEDN="o=Esempio,c=IT"
229 echo " base=\"$BASEDN\"..."
230 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
231 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" -M "$FILTER" "*" ref \
234 if test $RC != 0 ; then
235 echo "Search failed ($RC)!"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
240 BASEDN="o=Example,c=US"
241 FILTER="(seeAlso=cn=all staff,ou=Groups,$BASEDN)"
242 echo "searching filter=\"$FILTER\""
243 echo " attrs=\"seeAlso\""
244 echo " base=\"$BASEDN\"..."
245 echo "# searching filter=\"$FILTER\"" >> $SEARCHOUT
246 echo "# attrs=\"seeAlso\"" >> $SEARCHOUT
247 echo "# base=\"$BASEDN\"..." >> $SEARCHOUT
248 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" "$FILTER" seeAlso \
251 if test $RC != 0 ; then
252 echo "Search failed ($RC)!"
253 test $KILLSERVERS != no && kill -HUP $KILLPIDS
257 echo "Filtering ldapsearch results..."
258 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
259 echo "Filtering original ldif used to create database..."
260 . $LDIFFILTER < $RELAYOUT > $LDIFFLT
261 echo "Comparing filter output..."
262 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
264 if test $? != 0 ; then
265 echo "comparison failed - relay search/modification didn't succeed"
266 test $KILLSERVERS != no && kill -HUP $KILLPIDS
270 BASEDN="o=Example,c=US"
271 echo "changing password to database \"$BASEDN\"..."
272 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
273 -s $PASSWD "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
276 if test $RC != 0 ; then
277 echo "Passwd ExOp failed ($RC)!"
278 test $KILLSERVERS != no && kill -HUP $KILLPIDS
282 BASEDN="o=Beispiel,c=DE"
283 echo "binding with newly changed password to database \"$BASEDN\"..."
284 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
285 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
286 -w $PASSWD >> $TESTOUT 2>&1
288 if test $RC != 0 ; then
289 echo "WhoAmI failed ($RC)!"
290 test $KILLSERVERS != no && kill -HUP $KILLPIDS
294 BASEDN="o=Esempio,c=IT"
295 echo "comparing to database \"$BASEDN\"..."
296 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
297 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
298 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
300 if test $RC != 6 ; then
301 echo "Compare failed ($RC)!"
302 test $KILLSERVERS != no && kill -HUP $KILLPIDS
306 test $KILLSERVERS != no && kill -HUP $KILLPIDS