3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2006 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>.
20 echo "Test does not support $BACKEND backend"
25 echo "running defines.sh"
26 . $SRCDIR/scripts/defines.sh
28 if test "$ACI" = "acino" ; then
29 echo "ACI not enabled, test skipped"
33 mkdir -p $TESTDIR $DBDIR1
35 echo "Running slapadd to build slapd database..."
36 . $CONFFILTER $BACKEND $MONITORDB < $ACICONF > $CONF1
37 $SLAPADD -f $CONF1 -l $LDIFORDERED
39 if test $RC != 0 ; then
40 echo "slapadd failed ($RC)!"
44 echo "Starting slapd on TCP/IP port $PORT1..."
45 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
47 if test $WAIT != 0 ; then
55 echo "Testing slapd ACI access control..."
56 for i in 0 1 2 3 4 5; do
57 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
58 'objectclass=*' > /dev/null 2>&1
60 if test $RC = 0 ; then
63 echo "Waiting 5 seconds for slapd to start..."
67 if test $RC != 0 ; then
68 echo "ldapsearch failed ($RC)!"
69 test $KILLSERVERS != no && kill -HUP $KILLPIDS
73 cat /dev/null > $SEARCHOUT
74 cat /dev/null > $TESTOUT
77 BASEDN="dc=example,dc=com"
78 echo "Searching \"$BASEDN\" (should fail)..."
79 echo "# Searching \"$BASEDN\" (should fail)..." >> $SEARCHOUT
80 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
81 '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
83 if test $RC != 32 ; then
84 echo "ldapsearch should have failed with noSuchObject ($RC)!"
85 test $KILLSERVERS != no && kill -HUP $KILLPIDS
86 if test $RC = 0 ; then
93 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
95 echo "Testing ldapwhoami as ${BINDDN} (should fail)..."
96 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
98 if test $RC = 0 ; then
99 echo "ldapwhoami should have failed!"
100 test $KILLSERVERS != no && kill -HUP $KILLPIDS
105 echo "Writing ACIs as \"$MANAGERDN\"..."
106 $LDAPMODIFY -D "$MANAGERDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
107 >> $TESTOUT 2>&1 << EOMODS0
108 dn: dc=example,dc=com
111 OpenLDAPaci: 0#subtree#grant;d,c,s,r;[all]#group/groupOfUniqueNames/uniqueMe
112 mber#cn=ITD Staff,ou=Groups,dc=example,dc=com
113 OpenLDAPaci: 1#entry#grant;d;[all]#public#
115 dn: ou=People,dc=example,dc=com
118 OpenLDAPaci: 0#subtree#grant;x;userPassword#public#
119 OpenLDAPaci: 1#subtree#grant;w;userPassword#self#
120 OpenLDAPaci: 2#subtree#grant;w;userPassword#access-id#cn=Bjorn Jensen,ou=Inf
121 ormation Technology Division,ou=People,dc=example,dc=com
123 dn: ou=Groups,dc=example,dc=com
126 OpenLDAPaci: 0#entry#grant;s;[all]#public#
127 OpenLDAPaci: 1#children#grant;r;member;r;uniqueMember#access-id#cn=Bjorn Jen
128 sen,ou=Information Technology Division,ou=People,dc=example,dc=com
131 if test $RC != 0 ; then
132 echo "ldapmodify failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
137 # Search must succeed with no results
138 BASEDN="dc=example,dc=com"
139 echo "Searching \"$BASEDN\" (should succeed with no results)..."
140 echo "# Searching \"$BASEDN\" (should succeed with no results)..." >> $SEARCHOUT
141 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
142 '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
144 if test $RC != 0 ; then
145 ### TEMPORARY (see ITS#3963)
146 echo "ldapsearch failed ($RC)! IGNORED..."
147 ###echo "ldapsearch failed ($RC)!"
148 ###test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
154 echo "Testing ldapwhoami as ${BINDDN}..."
155 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
157 if test $RC != 0 ; then
158 echo "ldapwhoami failed ($RC)!"
159 test $KILLSERVERS != no && kill -HUP $KILLPIDS
163 # Search must succeed
164 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
166 BASEDN="dc=example,dc=com"
167 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
168 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
169 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
170 -D "$BINDDN" -w "$BINDPW" \
171 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
173 if test $RC != 0 ; then
174 echo "ldapsearch failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 # Passwd must succeed
180 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
182 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
184 echo "Setting \"$TGT\" password..."
185 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
186 -w "$BINDPW" -s "$NEWPW" \
187 -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
189 if test $RC != 0 ; then
190 echo "ldappasswd failed ($RC)!"
191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
195 # Re-change as self...
196 echo "Changing self password..."
199 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
201 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
202 -w "$BINDPW" -s "$NEWPW" \
203 -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
205 if test $RC != 0 ; then
206 echo "ldappasswd failed ($RC)!"
207 test $KILLSERVERS != no && kill -HUP $KILLPIDS
213 BASEDN="ou=Groups,dc=example,dc=com"
214 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
215 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
216 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
217 -D "$BINDDN" -w "$BINDPW" \
218 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
220 if test $RC != 0 ; then
221 echo "ldapsearch failed ($RC)!"
222 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
229 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..."
230 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..." >> $SEARCHOUT
231 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
232 -D "$BINDDN" -w "$BINDPW" \
233 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
235 if test $RC != 0 ; then
236 echo "ldapsearch failed ($RC)!"
237 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo "Filtering ldapsearch results..."
246 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
247 echo "Filtering original ldif used to create database..."
248 . $LDIFFILTER < $LDIF > $LDIFFLT
249 echo "Comparing filter output..."
250 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
252 if test $? != 0 ; then
253 echo "comparison failed - operations did not complete correctly"
257 echo ">>>>> Test succeeded"
259 test $KILLSERVERS != no && wait