4 echo "running defines.sh"
5 . $SRCDIR/scripts/defines.sh
7 mkdir -p $TESTDIR $DBDIR1
9 echo "Running slapadd to build slapd database..."
10 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $CONF1
11 $SLAPADD -f $CONF1 -l $LDIFORDERED
13 if test $RC != 0 ; then
14 echo "slapadd failed ($RC)!"
18 echo "Starting slapd on TCP/IP port $PORT1..."
19 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
21 if test $WAIT != 0 ; then
27 echo "Testing slapd modrdn operations..."
29 # Make sure we can search the database
30 for i in 0 1 2 3 4 5; do
31 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
32 'objectClass=*' > $INITOUT 2>&1
34 if test $RC = 0 ; then
37 echo "Waiting 5 seconds for slapd to start..."
41 if test $RC != 0 ; then
42 echo "ldapsearch failed ($RC)!"
47 # -r used to do remove of old rdn
49 echo "Testing modrdn(deleteoldrdn=0)..."
50 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD > \
51 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
54 if test $RC != 0 ; then
55 echo "ldapmodrdn failed ($RC)!"
60 echo "Testing modrdn(deleteoldrdn=1)..."
61 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
62 $TESTOUT 2>&1 'cn=James A Jones 2, ou=Information Technology Division, ou=People, o=University of Michigan, c=US' 'cn=James A Jones II'
65 if test $RC != 0 ; then
66 echo "ldapmodrdn failed ($RC)!"
71 # Ensure the new rdn's can be found
73 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
74 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
75 'cn=James A Jones III' > $SEARCHOUT 2>&1
77 if test $RC != 0 ; then
78 echo "ldapsearch failed ($RC)!"
79 test $KILLSERVERS != no && kill -HUP $KILLPIDS
84 LDIF=$MODRDNOUTMASTER1
86 echo "Filtering ldapsearch results..."
87 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
88 echo "Filtering original ldif used to create database..."
89 . $LDIFFILTER < $LDIF > $LDIFFLT
90 echo "Comparing filter output..."
91 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
93 if test $? != 0 ; then
94 echo "comparison failed - modrdn operations did not complete correctly"
95 test $KILLSERVERS != no && kill -HUP $KILLPIDS
100 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
101 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
102 'cn=James A Jones II' > $SEARCHOUT 2>&1
104 if test $RC != 0 ; then
105 echo "ldapsearch failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 LDIF=$MODRDNOUTMASTER2
113 echo "Filtering ldapsearch results..."
114 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
115 echo "Filtering original ldif used to create database..."
116 . $LDIFFILTER < $LDIF > $LDIFFLT
117 echo "Comparing filter output..."
118 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
120 if test $? != 0 ; then
121 echo "comparison failed - modrdn operations did not complete correctly"
122 test $KILLSERVERS != no && kill -HUP $KILLPIDS
126 # Ensure that you cannot find the entry for which the rdn was deleted as
129 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
130 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
131 'cn=James A Jones 2' > $SEARCHOUT 2>&1
133 if test $RC != 0 ; then
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
135 echo "ldapsearch failed ($RC)!"
138 $CMP $SEARCHOUT - < /dev/null > $CMPOUT
139 if test $? != 0 ; then
140 echo "failure: ldapsearch found attribute that was to be removed!"
141 test $KILLSERVERS != no && kill -HUP $KILLPIDS
145 echo "Using ldapsearch to retrieve all the entries..."
146 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
147 'objectClass=*' > $SEARCHOUT 2>&1
149 if test $RC != 0 ; then
150 test $KILLSERVERS != no && kill -HUP $KILLPIDS
151 echo "ldapsearch failed ($RC)!"
155 LDIF=$MODRDNOUTMASTER0
157 echo "Filtering ldapsearch results..."
158 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
159 echo "Filtering original ldif used to create database..."
160 . $LDIFFILTER < $LDIF > $LDIFFLT
161 echo "Comparing filter output..."
162 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
164 if test $? != 0 ; then
165 echo "comparison failed - modrdn operations did not complete correctly"
166 test $KILLSERVERS != no && kill -HUP $KILLPIDS
171 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
172 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT1 -w $PASSWD > \
173 /dev/null 2>&1 'cn=James A Jones III, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones 1'
176 if test $RC != 0 ; then
177 echo "ldapmodrdn failed ($RC)!"
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
182 # Test that you can use modrdn with an attribute value which was previously
185 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
186 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
187 'cn=James A Jones 1' > $SEARCHOUT 2>&1
190 test $KILLSERVERS != no && kill -HUP $KILLPIDS
192 if test $RC != 0 ; then
193 echo "ldapsearch failed ($RC)!"
197 LDIF=$MODRDNOUTMASTER3
199 echo "Filtering ldapsearch results..."
200 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
201 echo "Filtering original ldif used to create database..."
202 . $LDIFFILTER < $LDIF > $LDIFFLT
203 echo "Comparing filter output..."
204 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
206 if test $? != 0 ; then
207 echo "comparison failed - modrdn operations did not complete correctly"
211 echo ">>>>> Test succeeded"