3 if test $# -eq 0 ; then
8 if test $# -eq 1 ; then
12 echo "running defines.sh $SRCDIR $BACKEND"
13 . $SRCDIR/scripts/defines.sh
15 echo "Cleaning up in $DBDIR..."
19 echo "Running slapadd to build slapd database..."
20 $LDIF2LDBM -f $CONF -l $LDIF
22 if test $RC != 0 ; then
23 echo "slapadd failed!"
27 echo "Starting slapd on TCP/IP port $PORT..."
28 $SLAPD -f $CONF -p $PORT -d $LVL $TIMING > $MASTERLOG 2>&1 &
30 echo "Testing slapd modrdn operations..."
32 # Make sure we can search the database
33 for i in 0 1 2 3 4 5; do
34 $LDAPSEARCH -s base -b "$MONITOR" -h localhost -p $PORT \
35 'objectclass=*' > /dev/null 2>&1
37 if test $RC = 1 ; then
38 echo "Waiting 5 seconds for slapd to start..."
43 if test $RC != 0 ; then
44 echo "ldapsearch failed!"
49 # -r used to do remove of old rdn
51 echo "Testing modrdn(deleteoldrdn=0)..."
52 $LDAPMODRDN -v -D "$MANAGERDN" -h localhost -p $PORT -w $PASSWD > \
53 $TESTOUT 2>&1 'cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US' 'cn=James A Jones III'
56 if test $RC != 0 ; then
57 echo "ldapmodrdn failed!"
62 echo "Testing modrdn(deleteoldrdn=1)..."
63 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD >> \
64 $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'
67 if test $RC != 0 ; then
68 echo "ldapmodrdn failed!"
73 # Ensure the new rdn's can be found
75 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones III)..."
76 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
77 'cn=James A Jones III' > $SEARCHOUT 2>&1
79 if test $RC != 0 ; then
80 echo "ldapsearch failed!"
86 LDIF=$MODRDNOUTMASTER1
88 echo "Filtering ldapsearch results..."
89 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
90 echo "Filtering original ldif used to create database..."
91 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
92 echo "Comparing filter output..."
93 cmp $SEARCHFLT $LDIFFLT
95 if test $? != 0 ; then
96 echo "comparison failed - modrdn operations did not complete correctly"
102 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones II)..."
103 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
104 'cn=James A Jones II' > $SEARCHOUT 2>&1
106 if test $RC != 0 ; then
107 echo "ldapsearch failed!"
113 LDIF=$MODRDNOUTMASTER2
115 echo "Filtering ldapsearch results..."
116 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
117 echo "Filtering original ldif used to create database..."
118 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
119 echo "Comparing filter output..."
120 cmp $SEARCHFLT $LDIFFLT
122 if test $? != 0 ; then
123 echo "comparison failed - modrdn operations did not complete correctly"
128 # Ensure that you cannot find the entry for which the rdn was deleted as
131 echo "Using ldapsearch to retrieve entries using removed rdn (cn=James A Jones 2)..."
132 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
133 'cn=James A Jones 2' > $SEARCHOUT 2>&1
135 if test $RC != 0 ; then
137 echo "ldapsearch failed!"
140 cmp $SEARCHOUT /dev/null
141 if test $? != 0 ; then
142 echo "failure: ldapsearch found attribute that was to be removed!"
147 echo "Using ldapsearch to retrieve all the entries..."
148 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
149 'objectClass=*' > $SEARCHOUT 2>&1
151 if test $RC != 0 ; then
153 echo "ldapsearch failed!"
157 LDIF=$MODRDNOUTMASTER0
159 echo "Filtering ldapsearch results..."
160 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
161 echo "Filtering original ldif used to create database..."
162 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
163 echo "Comparing filter output..."
164 cmp $SEARCHFLT $LDIFFLT
166 if test $? != 0 ; then
167 echo "comparison failed - modrdn operations did not complete correctly"
173 echo "Testing modrdn(deleteoldrdn=1), modrdn with new rdn already an att val..."
174 $LDAPMODRDN -v -D "$MANAGERDN" -r -h localhost -p $PORT -w $PASSWD > \
175 /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'
178 if test $RC != 0 ; then
179 echo "ldapmodrdn failed!"
184 # Test that you can use modrdn with an attribute value which was previously
187 echo "Using ldapsearch to retrieve entries using new rdn (cn=James A Jones 1)..."
188 $LDAPSEARCH -S "" -b "$BASEDN" -h localhost -p $PORT \
189 'cn=James A Jones 1' > $SEARCHOUT 2>&1
191 if test $RC != 0 ; then
192 echo "ldapsearch failed!"
198 LDIF=$MODRDNOUTMASTER3
200 echo "Filtering ldapsearch results..."
201 . $SRCDIR/scripts/acfilter.sh < $SEARCHOUT > $SEARCHFLT
202 echo "Filtering original ldif used to create database..."
203 . $SRCDIR/scripts/acfilter.sh < $LDIF > $LDIFFLT
204 echo "Comparing filter output..."
205 cmp $SEARCHFLT $LDIFFLT
208 if test $? != 0 ; then
209 echo "comparison failed - modrdn operations did not complete correctly"
213 echo ">>>>> Test succeeded"
217 # echo "modrdn test not yet written"