3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2005 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 $DBDIR1
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
23 $SLAPADD -f $CONF1 -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
39 echo "Testing slapd modrdn operations..."
41 # Make sure we can search the database
42 for i in 0 1 2 3 4 5; do
43 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
44 'objectClass=*' > $INITOUT 2>&1
46 if test $RC = 0 ; then
49 echo "Waiting 5 seconds for slapd to start..."
53 if test $RC != 0 ; then
54 echo "ldapsearch failed ($RC)!"
59 # -r used to do remove of old rdn
61 echo "Testing modrdn(deleteoldrdn=0)..."
62 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
63 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones III'
66 if test $RC != 0 ; then
67 echo "ldapmodrdn failed ($RC)!"
72 echo "Testing modrdn(deleteoldrdn=1)..."
73 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
74 $TESTOUT 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, dc=example, dc=com' 'cn=James A Jones II'
77 if test $RC != 0 ; then
78 echo "ldapmodrdn failed ($RC)!"
83 # Ensure the new rdn's can be found
85 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
86 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
87 'cn=James A Jones III' > $SEARCHOUT 2>&1
89 if test $RC != 0 ; then
90 echo "ldapsearch failed ($RC)!"
91 test $KILLSERVERS != no && kill -HUP $KILLPIDS
96 LDIF=$MODRDNOUTMASTER1
98 echo "Filtering ldapsearch results..."
99 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
100 echo "Filtering original ldif used to create database..."
101 . $LDIFFILTER < $LDIF > $LDIFFLT
102 echo "Comparing filter output..."
103 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
105 if test $? != 0 ; then
106 echo "comparison failed - modrdn operations did not complete correctly"
107 test $KILLSERVERS != no && kill -HUP $KILLPIDS
112 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
113 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
114 'cn=James A Jones II' > $SEARCHOUT 2>&1
116 if test $RC != 0 ; then
117 echo "ldapsearch failed ($RC)!"
118 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 LDIF=$MODRDNOUTMASTER2
125 echo "Filtering ldapsearch results..."
126 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
127 echo "Filtering original ldif used to create database..."
128 . $LDIFFILTER < $LDIF > $LDIFFLT
129 echo "Comparing filter output..."
130 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
132 if test $? != 0 ; then
133 echo "comparison failed - modrdn operations did not complete correctly"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 # Ensure that you cannot find the entry for which the rdn was deleted as
141 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
142 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
143 'cn=James A Jones 2' > $SEARCHOUT 2>&1
145 if test $RC != 0 ; then
146 test $KILLSERVERS != no && kill -HUP $KILLPIDS
147 echo "ldapsearch failed ($RC)!"
150 $CMP $SEARCHOUT - < /dev/null > $CMPOUT
151 if test $? != 0 ; then
152 echo "failure: ldapsearch found attribute that was to be removed!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 echo "Using ldapsearch to retrieve all the entries..."
158 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
159 'objectClass=*' > $SEARCHOUT 2>&1
161 if test $RC != 0 ; then
162 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 echo "ldapsearch failed ($RC)!"
167 LDIF=$MODRDNOUTMASTER0
169 echo "Filtering ldapsearch results..."
170 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
171 echo "Filtering original ldif used to create database..."
172 . $LDIFFILTER < $LDIF > $LDIFFLT
173 echo "Comparing filter output..."
174 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
176 if test $? != 0 ; then
177 echo "comparison failed - modrdn operations did not complete correctly"
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
183 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
184 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
185 /dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, dc=example, dc=com' 'cn=James A Jones 1'
188 if test $RC != 0 ; then
189 echo "ldapmodrdn failed ($RC)!"
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
194 # Test that you can use modrdn with an attribute value which was previously
197 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
198 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
199 'cn=James A Jones 1' > $SEARCHOUT 2>&1
202 test $KILLSERVERS != no && kill -HUP $KILLPIDS
204 if test $RC != 0 ; then
205 echo "ldapsearch failed ($RC)!"
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"
223 echo ">>>>> Test succeeded"