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>.
23 echo "Test does not support $BACKEND backend"
28 echo "running defines.sh"
29 . $SRCDIR/scripts/defines.sh
31 if test "$ACI" = "acino" ; then
32 echo "ACI not enabled; skipping..."
36 mkdir -p $TESTDIR $DBDIR1
38 echo "Running slapadd to build slapd database..."
39 . $CONFFILTER $BACKEND $MONITORDB < $ACICONF > $CONF1
40 $SLAPADD -f $CONF1 -l $LDIFORDERED
42 if test $RC != 0 ; then
43 echo "slapadd failed ($RC)!"
47 echo "Starting slapd on TCP/IP port $PORT1..."
48 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
50 if test $WAIT != 0 ; then
56 echo "Testing slapd ACI access control..."
57 for i in 0 1 2 3 4 5; do
58 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
59 'objectclass=*' > /dev/null 2>&1
61 if test $RC = 0 ; then
64 echo "Waiting 5 seconds for slapd to start..."
68 if test $RC != 0 ; then
69 echo "ldapsearch failed ($RC)!"
70 test $KILLSERVERS != no && kill -HUP $KILLPIDS
74 cat /dev/null > $SEARCHOUT
75 cat /dev/null > $TESTOUT
78 BASEDN="dc=example,dc=com"
79 echo "Searching \"$BASEDN\" (should fail)..."
80 echo "# Searching \"$BASEDN\" (should fail)..." >> $SEARCHOUT
81 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
82 '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
84 if test $RC != 32 ; then
85 echo "ldapsearch should have failed with noSuchObject ($RC)!"
86 test $KILLSERVERS != no && kill -HUP $KILLPIDS
87 if test $RC = 0 ; then
94 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
96 echo "Testing ldapwhoami as ${BINDDN} (should fail)..."
97 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
99 if test $RC = 0 ; then
100 echo "ldapwhoami should have failed!"
101 test $KILLSERVERS != no && kill -HUP $KILLPIDS
106 echo "Writing ACIs as \"$MANAGERDN\"..."
107 $LDAPMODIFY -D "$MANAGERDN" -w $PASSWD -h $LOCALHOST -p $PORT1 \
108 >> $TESTOUT 2>&1 << EOMODS0
109 dn: dc=example,dc=com
112 OpenLDAPaci: 0#subtree#grant;d,c,s,r;[all]#group/groupOfUniqueNames/uniqueMe
113 mber#cn=ITD Staff,ou=Groups,dc=example,dc=com
114 OpenLDAPaci: 1#entry#grant;d;[all]#public#
116 dn: ou=People,dc=example,dc=com
119 OpenLDAPaci: 0#subtree#grant;x;userPassword#public#
120 OpenLDAPaci: 1#subtree#grant;w;userPassword#self#
121 OpenLDAPaci: 2#subtree#grant;w;userPassword#access-id#cn=Bjorn Jensen,ou=Inf
122 ormation Technology Division,ou=People,dc=example,dc=com
124 dn: ou=Groups,dc=example,dc=com
127 OpenLDAPaci: 0#entry#grant;s;[all]#public#
128 OpenLDAPaci: 1#children#grant;r;member;r;uniqueMember#access-id#cn=Bjorn Jen
129 sen,ou=Information Technology Division,ou=People,dc=example,dc=com
132 if test $RC != 0 ; then
133 echo "ldapmodify failed ($RC)!"
134 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 # Search must succeed with no results
139 BASEDN="dc=example,dc=com"
140 echo "Searching \"$BASEDN\" (should succeed with no results)..."
141 echo "# Searching \"$BASEDN\" (should succeed with no results)..." >> $SEARCHOUT
142 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
143 '(objectclass=*)' >> $SEARCHOUT 2>> $TESTOUT
145 if test $RC != 0 ; then
146 ### TEMPORARY (see ITS#3963)
147 echo "ldapsearch failed ($RC)! IGNORED..."
148 ###echo "ldapsearch failed ($RC)!"
149 ###test $KILLSERVERS != no && kill -HUP $KILLPIDS
153 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
155 echo "Testing ldapwhoami as ${BINDDN}..."
156 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "$BINDDN" -w $BINDPW
158 if test $RC != 0 ; then
159 echo "ldapwhoami failed ($RC)!"
160 test $KILLSERVERS != no && kill -HUP $KILLPIDS
164 # Search must succeed
165 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
167 BASEDN="dc=example,dc=com"
168 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
169 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
170 $LDAPSEARCH -s base -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
171 -D "$BINDDN" -w "$BINDPW" \
172 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
174 if test $RC != 0 ; then
175 echo "ldapsearch failed ($RC)!"
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
180 # Passwd must succeed
181 BINDDN="cn=Bjorn Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
183 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
185 echo "Setting \"$TGT\" password..."
186 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
187 -w "$BINDPW" -s "$NEWPW" \
188 -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
190 if test $RC != 0 ; then
191 echo "ldappasswd failed ($RC)!"
192 test $KILLSERVERS != no && kill -HUP $KILLPIDS
196 # Re-change as self...
197 echo "Changing self password..."
200 TGT="cn=John Doe,ou=Information Technology Division,ou=People,dc=example,dc=com"
202 $LDAPPASSWD -h $LOCALHOST -p $PORT1 \
203 -w "$BINDPW" -s "$NEWPW" \
204 -D "$BINDDN" "$TGT" >> $TESTOUT 2>&1
206 if test $RC != 0 ; then
207 echo "ldappasswd failed ($RC)!"
208 test $KILLSERVERS != no && kill -HUP $KILLPIDS
214 BASEDN="ou=Groups,dc=example,dc=com"
215 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..."
216 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed)..." >> $SEARCHOUT
217 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
218 -D "$BINDDN" -w "$BINDPW" \
219 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
221 if test $RC != 0 ; then
222 echo "ldapsearch failed ($RC)!"
223 test $KILLSERVERS != no && kill -HUP $KILLPIDS
228 BINDDN="cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com"
230 echo "Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..."
231 echo "# Searching \"$BASEDN\" as \"$BINDDN\" (should succeed with no results)..." >> $SEARCHOUT
232 $LDAPSEARCH -s one -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
233 -D "$BINDDN" -w "$BINDPW" \
234 '(objectClass=*)' >> $SEARCHOUT 2>> $TESTOUT
236 if test $RC != 0 ; then
237 echo "ldapsearch failed ($RC)!"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
242 test $KILLSERVERS != no && kill -HUP $KILLPIDS
246 echo "Filtering ldapsearch results..."
247 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
248 echo "Filtering original ldif used to create database..."
249 . $LDIFFILTER < $LDIF > $LDIFFLT
250 echo "Comparing filter output..."
251 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
253 if test $? != 0 ; then
254 echo "comparison failed - operations did not complete correctly"
258 echo ">>>>> Test succeeded"