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 >> $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: +1 313 555 4178
130 dn: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
133 seeAlso: cn=Ursula Hampster,ou=Alumni Association,ou=People,$BASEDN
136 description: Just added self in $BASEDN virtual naming context
139 dn: cn=Mark Elliot,ou=Alumni Association,ou=People,$BASEDN
142 dn: cn=John Doe,ou=Information Technology Division,ou=People,$BASEDN
144 newrdn: cn=John P. Doe
147 dn: cn=Jane Doe,ou=Alumni Association,ou=People,$BASEDN
149 newrdn: cn=Jane Q. Doe
151 newsuperior: ou=Information Technology Division,ou=People,$BASEDN
155 if test $RC != 0 ; then
156 echo "Modify failed ($RC)!"
157 test $KILLSERVERS != no && kill -HUP $KILLPIDS
161 BASEDN="o=Esempio,c=IT"
162 echo "searching base=\"$BASEDN\"..."
163 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASEDN" >> $SEARCHOUT 2>&1
165 if test $RC != 0 ; then
166 echo "Search failed ($RC)!"
167 test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 echo "Filtering ldapsearch results..."
172 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
173 echo "Filtering original ldif used to create database..."
174 . $LDIFFILTER < $RELAYOUT > $LDIFFLT
175 echo "Comparing filter output..."
176 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
178 if test $? != 0 ; then
179 echo "comparison failed - relay search/modification didn't succeed"
180 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 BASEDN="o=Example,c=US"
185 echo "changing password to database \"$BASEDN\"..."
186 $LDAPPASSWD -h $LOCALHOST -p $PORT1 -D "cn=Manager,$BASEDN" -w $PASSWD \
187 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
188 -s $PASSWD >> $TESTOUT 2>&1
190 if test $RC != 0 ; then
191 echo "Passwd ExOp failed ($RC)!"
192 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 echo "binding with newly changed password to database \"$BASEDN\"..."
197 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 \
198 -D "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
199 -w $PASSWD >> $TESTOUT 2>&1
201 if test $RC != 0 ; then
202 echo "WhoAmI failed ($RC)!"
203 test $KILLSERVERS != no && kill -HUP $KILLPIDS
207 BASEDN="o=Esempio,c=IT"
208 echo "comparing to database \"$BASEDN\"..."
209 $LDAPCOMPARE -h $LOCALHOST -p $PORT1 \
210 "cn=Added User,ou=Alumni Association,ou=People,$BASEDN" \
211 "seeAlso:cn=All Staff,ou=Groups,$BASEDN" >> $TESTOUT 2>&1
213 if test $RC != 6 ; then
214 echo "Compare failed ($RC)!"
215 test $KILLSERVERS != no && kill -HUP $KILLPIDS
219 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 echo ">>>>> Test succeeded"