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>.
20 echo "Test does not support $BACKEND backend"
24 echo "running defines.sh"
25 . $SRCDIR/scripts/defines.sh
27 mkdir -p $TESTDIR $DBDIR1
29 echo "Running slapadd to build slapd database..."
30 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $CONF1
31 $SLAPADD -f $CONF1 -l $LDIFORDERED
33 if test $RC != 0 ; then
34 echo "slapadd failed ($RC)!"
38 echo "Starting slapd on TCP/IP port $PORT1..."
39 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
41 if test $WAIT != 0 ; then
49 echo "Testing slapd access control..."
50 for i in 0 1 2 3 4 5; do
51 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
52 'objectclass=*' > /dev/null 2>&1
54 if test $RC = 0 ; then
57 echo "Waiting 5 seconds for slapd to start..."
61 if test $RC != 0 ; then
62 echo "ldapsearch failed ($RC)!"
63 test $KILLSERVERS != no && kill -HUP $KILLPIDS
67 cat /dev/null > $SEARCHOUT
69 echo "# Try to read an entry inside the Alumni Association container.
70 # It should give us noSuchObject if we're not bound..." \
72 # FIXME: temporarily remove the "No such object" message to make
73 # the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
74 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "(objectclass=*)" \
75 2>&1 | grep -v "^No such object" >> $SEARCHOUT
77 echo "# ... and should return all attributes if we're bound as anyone
80 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
81 -D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
84 # Check group access. Try to modify Babs' entry. Two attempts:
85 # 1) bound as "James A Jones 1" - should fail
86 # 2) bound as "Bjorn Jensen" - should succeed
88 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
89 $TESTOUT 2>&1 << EOMODS5
98 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
99 $TESTOUT 2>&1 << EOMODS6
103 homephone: +1 313 555 5444
108 # Try to add a "member" attribute to the "ITD Staff" group. It should
109 # fail when we add some DN other than our own, and should succeed when
112 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
113 $TESTOUT 2>&1 << EOMODS1
115 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
118 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
122 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
123 $TESTOUT 2>&1 << EOMODS2
126 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
129 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
133 # Try to modify the "ITD Staff" group. Two attempts are made:
134 # 1) bound as "James A Jones 1" - should fail
135 # 2) bound as "Bjorn Jensen" - should succeed
137 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
138 $TESTOUT 2>&1 << EOMODS3
140 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
146 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
147 $TESTOUT 2>&1 << EOMODS4
151 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
162 # Try to modify the "ITD Staff" group. Two attempts are made:
163 # 1) bound as "James A Jones 1" - should succeed
164 # 2) bound as "Barbara Jensen" - should fail
165 # should exploit sets
167 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
168 $TESTOUT 2>&1 << EOMODS5
169 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
172 description: added by jaj (should succeed)
176 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
177 $TESTOUT 2>&1 << EOMODS6
178 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
181 description: added by bjensen (should fail)
185 $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
186 $TESTOUT 2>&1 << EOMODS7
187 dn: ou=Add & Delete,dc=example,dc=com
189 objectClass: organizationalUnit
193 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
194 $TESTOUT 2>&1 << EOMODS8
195 dn: cn=Added by Babs (must fail),ou=Add & Delete,dc=example,dc=com
197 objectClass: inetOrgPerson
198 cn: Added by Babs (must fail)
202 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
203 $TESTOUT 2>&1 << EOMODS9
204 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
206 objectClass: inetOrgPerson
207 cn: Added by Bjorn (must succeed)
210 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
212 objectClass: inetOrgPerson
213 cn: Added by Bjorn (will be deleted)
216 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
218 objectClass: inetOrgPerson
219 cn: Added by Bjorn (will be renamed)
222 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
225 description: this attribute value has been added __after__entry creation
226 description: this attribute value will be deleted by Babs (must succeed)
227 description: Bjorn will try to delete this attribute value (should fail)
231 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
232 $TESTOUT 2>&1 << EOMODS10
233 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
237 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
238 $TESTOUT 2>&1 << EOMODS11
239 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
241 newrdn: cn=Added by Bjorn (renamed by Bjorn)
245 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
246 $TESTOUT 2>&1 << EOMODS12
247 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
249 newrdn: cn=Added by Bjorn (renamed by Babs)
253 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
254 $TESTOUT 2>&1 << EOMODS13
255 dn: cn=Added by Bjorn (will be renamed),ou=Add & Delete,dc=example,dc=com
257 newrdn: cn=Added by Bjorn (renamed by Jaj)
261 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
262 $TESTOUT 2>&1 << EOMODS14
263 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
266 description: Bjorn will try to delete this attribute value (should fail)
270 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
271 $TESTOUT 2>&1 << EOMODS15
272 dn: cn=Added by Bjorn (will be deleted),ou=Add & Delete,dc=example,dc=com
275 dn: cn=Added by Bjorn (must succeed),ou=Add & Delete,dc=example,dc=com
278 description: this attribute value will be deleted by Babs (must succeed)
282 echo "Using ldapsearch to retrieve all the entries..."
283 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
284 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
285 'objectClass=*' >> $SEARCHOUT 2>&1
287 test $KILLSERVERS != no && kill -HUP $KILLPIDS
288 if test $RC != 0 ; then
289 echo "ldapsearch failed ($RC)!"
295 echo "Filtering ldapsearch results..."
296 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
297 echo "Filtering original ldif used to create database..."
298 . $LDIFFILTER < $LDIF > $LDIFFLT
299 echo "Comparing filter output..."
300 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
302 if test $? != 0 ; then
303 echo "comparison failed - operations did not complete correctly"
307 echo ">>>>> Test succeeded"