5 if test $# -ge 1 ; then
9 . $SRCDIR/scripts/args.sh $*
11 echo "running defines.sh"
12 . $SRCDIR/scripts/defines.sh
14 echo "Cleaning up in $DBDIR..."
18 echo "Running slapadd to build slapd database..."
19 . $CONFFILTER $BACKEND $MONITORDB < $CONF > $DBCONF
20 $SLAPADD -f $DBCONF -l $LDIFORDERED
22 if test $RC != 0 ; then
23 echo "slapadd failed ($RC)!"
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $DBCONF -h $MASTERURI -d $LVL $TIMING > $MASTERLOG 2>&1 &
30 if test $WAIT != 0 ; then
34 echo "Testing slapd modrdn operations..."
36 # Make sure we can search the database
37 for i in 0 1 2 3 4 5; do
38 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
39 'objectClass=*' > $INITOUT 2>&1
41 if test $RC = 0 ; then
44 echo "Waiting 5 seconds for slapd to start..."
48 if test $RC != 0 ; then
49 echo "ldapsearch failed ($RC)!"
54 # -r used to do remove of old rdn
56 echo "Testing modrdn(deleteoldrdn=0)..."
57 $LDAPMODRDN -D "$MANAGERDN" -h $LOCALHOST -p $PORT -w $PASSWD > \
58 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
61 if test $RC != 0 ; then
62 echo "ldapmodrdn failed ($RC)!"
67 echo "Testing modrdn(deleteoldrdn=1)..."
68 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT -w $PASSWD >> \
69 $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'
72 if test $RC != 0 ; then
73 echo "ldapmodrdn failed ($RC)!"
78 # Ensure the new rdn's can be found
80 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
81 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
82 'cn=James A Jones III' > $SEARCHOUT 2>&1
84 if test $RC != 0 ; then
85 echo "ldapsearch failed ($RC)!"
91 LDIF=$MODRDNOUTMASTER1
93 echo "Filtering ldapsearch results..."
94 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
95 echo "Filtering original ldif used to create database..."
96 . $LDIFFILTER < $LDIF > $LDIFFLT
97 echo "Comparing filter output..."
98 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
100 if test $? != 0 ; then
101 echo "comparison failed - modrdn operations did not complete correctly"
107 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
108 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
109 'cn=James A Jones II' > $SEARCHOUT 2>&1
111 if test $RC != 0 ; then
112 echo "ldapsearch failed ($RC)!"
118 LDIF=$MODRDNOUTMASTER2
120 echo "Filtering ldapsearch results..."
121 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
122 echo "Filtering original ldif used to create database..."
123 . $LDIFFILTER < $LDIF > $LDIFFLT
124 echo "Comparing filter output..."
125 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
127 if test $? != 0 ; then
128 echo "comparison failed - modrdn operations did not complete correctly"
133 # Ensure that you cannot find the entry for which the rdn was deleted as
136 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
137 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
138 'cn=James A Jones 2' > $SEARCHOUT 2>&1
140 if test $RC != 0 ; then
142 echo "ldapsearch failed ($RC)!"
145 $CMP $SEARCHOUT - < /dev/null > $CMPOUT
146 if test $? != 0 ; then
147 echo "failure: ldapsearch found attribute that was to be removed!"
152 echo "Using ldapsearch to retrieve all the entries..."
153 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
154 'objectClass=*' > $SEARCHOUT 2>&1
156 if test $RC != 0 ; then
158 echo "ldapsearch failed ($RC)!"
162 LDIF=$MODRDNOUTMASTER0
164 echo "Filtering ldapsearch results..."
165 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
166 echo "Filtering original ldif used to create database..."
167 . $LDIFFILTER < $LDIF > $LDIFFLT
168 echo "Comparing filter output..."
169 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
171 if test $? != 0 ; then
172 echo "comparison failed - modrdn operations did not complete correctly"
178 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
179 $LDAPMODRDN -D "$MANAGERDN" -r -h $LOCALHOST -p $PORT -w $PASSWD > \
180 /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'
183 if test $RC != 0 ; then
184 echo "ldapmodrdn failed ($RC)!"
189 # Test that you can use modrdn with an attribute value which was previously
192 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
193 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT \
194 'cn=James A Jones 1' > $SEARCHOUT 2>&1
199 if test $RC != 0 ; then
200 echo "ldapsearch failed ($RC)!"
204 LDIF=$MODRDNOUTMASTER3
206 echo "Filtering ldapsearch results..."
207 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
208 echo "Filtering original ldif used to create database..."
209 . $LDIFFILTER < $LDIF > $LDIFFLT
210 echo "Comparing filter output..."
211 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
213 if test $? != 0 ; then
214 echo "comparison failed - modrdn operations did not complete correctly"
218 echo ">>>>> Test succeeded"