3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2017 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 mkdir -p $TESTDIR $DBDIR1A $DBDIR1B
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $CONF2DB > $CONF1
23 $SLAPADD -f $CONF1 -b "$BASEDN" -l $LDIFORDERED
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
33 if test $WAIT != 0 ; then
41 echo "Testing slapd modrdn operations..."
43 # Make sure we can search the database
44 for i in 0 1 2 3 4 5; do
45 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
46 'objectClass=*' > $INITOUT 2>&1
48 if test $RC = 0 ; then
51 echo "Waiting 5 seconds for slapd to start..."
55 if test $RC != 0 ; then
56 echo "ldapsearch failed ($RC)!"
57 test $KILLSERVERS != no && kill -HUP $KILLPIDS
61 # -r used to do remove of old rdn
63 echo "Testing modrdn(deleteoldrdn=0)..."
64 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
65 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones III'
68 if test $RC != 0 ; then
69 echo "ldapmodrdn failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 echo "Testing modrdn(deleteoldrdn=1)..."
75 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
76 $TESTOUT 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com' 'cn=James A Jones II'
79 if test $RC != 0 ; then
80 echo "ldapmodrdn failed ($RC)!"
81 test $KILLSERVERS != no && kill -HUP $KILLPIDS
85 # Ensure the new rdn's can be found
87 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
88 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
89 'cn=James A Jones III' > $SEARCHOUT 2>&1
91 if test $RC != 0 ; then
92 echo "ldapsearch failed ($RC)!"
93 test $KILLSERVERS != no && kill -HUP $KILLPIDS
98 LDIF=$MODRDNOUTMASTER1
100 echo "Filtering ldapsearch results..."
101 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
102 echo "Filtering original ldif used to create database..."
103 $LDIFFILTER < $LDIF > $LDIFFLT
104 echo "Comparing filter output..."
105 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
107 if test $? != 0 ; then
108 echo "comparison failed - modrdn operations did not complete correctly"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
115 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
116 'cn=James A Jones II' > $SEARCHOUT 2>&1
118 if test $RC != 0 ; then
119 echo "ldapsearch failed ($RC)!"
120 test $KILLSERVERS != no && kill -HUP $KILLPIDS
125 LDIF=$MODRDNOUTMASTER2
127 echo "Filtering ldapsearch results..."
128 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
129 echo "Filtering original ldif used to create database..."
130 $LDIFFILTER < $LDIF > $LDIFFLT
131 echo "Comparing filter output..."
132 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
134 if test $? != 0 ; then
135 echo "comparison failed - modrdn operations did not complete correctly"
136 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 # Ensure that you cannot find the entry for which the rdn was deleted as
143 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
144 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
145 'cn=James A Jones 2' > $SEARCHOUT 2>&1
147 if test $RC != 0 ; then
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
149 echo "ldapsearch failed ($RC)!"
152 $CMP $SEARCHOUT - < /dev/null > $CMPOUT
153 if test $? != 0 ; then
154 echo "failure: ldapsearch found attribute that was to be removed!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 echo "Using ldapsearch to retrieve all the entries..."
160 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
161 'objectClass=*' > $SEARCHOUT 2>&1
163 if test $RC != 0 ; then
164 test $KILLSERVERS != no && kill -HUP $KILLPIDS
165 echo "ldapsearch failed ($RC)!"
169 LDIF=$MODRDNOUTMASTER0
171 echo "Filtering ldapsearch results..."
172 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
173 echo "Filtering original ldif used to create database..."
174 $LDIFFILTER < $LDIF > $LDIFFLT
175 echo "Comparing filter output..."
176 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
178 if test $? != 0 ; then
179 echo "comparison failed - modrdn operations did not complete correctly"
180 test $KILLSERVERS != no && kill -HUP $KILLPIDS
184 # Test that you can use modrdn with an attribute value which was previously
187 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
188 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
189 /dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
192 if test $RC != 0 ; then
193 echo "ldapmodrdn failed ($RC)!"
194 test $KILLSERVERS != no && kill -HUP $KILLPIDS
198 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
199 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
200 'cn=James A Jones 1' > $SEARCHOUT 2>&1
203 if test $RC != 0 ; then
204 echo "ldapsearch failed ($RC)!"
205 test $KILLSERVERS != no && kill -HUP $KILLPIDS
209 LDIF=$MODRDNOUTMASTER3
211 echo "Filtering ldapsearch results..."
212 $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
213 echo "Filtering original ldif used to create database..."
214 $LDIFFILTER < $LDIF > $LDIFFLT
215 echo "Comparing filter output..."
216 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
218 if test $? != 0 ; then
219 echo "comparison failed - modrdn operations did not complete correctly"
220 test $KILLSERVERS != no && kill -HUP $KILLPIDS
224 echo "Testing modrdn to another database (should fail with affectsMultipleDSAs)"
225 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
226 $TESTOUT 2>&1 'cn=All Staff,ou=Groups,dc=example,dc=com' 'cn=Everyone'
230 echo "ldapmodrdn succeeded, should have failed!"
231 test $KILLSERVERS != no && kill -HUP $KILLPIDS
237 echo "ldapmodrdn failed ($RC)!"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243 echo "Testing modrdn with newSuperior = target (should fail with unwillingToPerform)"
244 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
245 $TESTOUT 2>&1 -s 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' \
246 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
251 echo "ldapmodrdn succeeded, should have failed!"
252 test $KILLSERVERS != no && kill -HUP $KILLPIDS
258 echo "ldapmodrdn failed ($RC)!"
259 test $KILLSERVERS != no && kill -HUP $KILLPIDS
264 echo "Testing modrdn with newRdn exact same as target..."
265 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
266 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
273 echo "ldapmodrdn failed ($RC)!"
274 test $KILLSERVERS != no && kill -HUP $KILLPIDS
279 echo "Testing modrdn with newRdn same as target, changed case..."
280 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
281 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A JONES 1'
288 echo "ldapmodrdn failed ($RC)!"
289 test $KILLSERVERS != no && kill -HUP $KILLPIDS
294 test $KILLSERVERS != no && kill -HUP $KILLPIDS
296 echo ">>>>> Test succeeded"
298 test $KILLSERVERS != no && wait