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>.
16 echo "running defines.sh"
17 . $SRCDIR/scripts/defines.sh
19 mkdir -p $TESTDIR $DBDIR1
21 echo "Running slapadd to build slapd database..."
22 . $CONFFILTER $BACKEND $MONITORDB < $ACLCONF > $CONF1
23 $SLAPADD -f $CONF1 -l $LDIFORDERED
25 if test $RC != 0 ; then
26 echo "slapadd failed ($RC)!"
30 echo "Starting slapd on TCP/IP port $PORT1..."
31 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
33 if test $WAIT != 0 ; then
39 echo "Testing slapd access control..."
40 for i in 0 1 2 3 4 5; do
41 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
42 'objectclass=*' > /dev/null 2>&1
44 if test $RC = 0 ; then
47 echo "Waiting 5 seconds for slapd to start..."
51 if test $RC != 0 ; then
52 echo "ldapsearch failed ($RC)!"
53 test $KILLSERVERS != no && kill -HUP $KILLPIDS
57 cat /dev/null > $SEARCHOUT
59 echo "# Try to read an entry inside the Alumni Association container.
60 # It should give us noSuchObject if we're not bound..." \
62 # FIXME: temporarily remove the "No such object" message to make
63 # the test succeed even if SLAP_ACL_HONOR_DISCLOSE is not #define'd
64 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "(objectclass=*)" \
65 2>&1 | grep -v "^No such object" >> $SEARCHOUT
67 echo "# ... and should return all attributes if we're bound as anyone
70 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
71 -D "$BABSDN" -w bjensen "(objectclass=*)" >> $SEARCHOUT 2>&1
74 # Check group access. Try to modify Babs' entry. Two attempts:
75 # 1) bound as "James A Jones 1" - should fail
76 # 2) bound as "Bjorn Jensen" - should succeed
78 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
79 $TESTOUT 2>&1 << EOMODS5
88 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
89 $TESTOUT 2>&1 << EOMODS6
93 homephone: +1 313 555 5444
98 # Try to add a "member" attribute to the "ITD Staff" group. It should
99 # fail when we add some DN other than our own, and should succeed when
102 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
103 $TESTOUT 2>&1 << EOMODS1
105 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
108 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
112 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
113 $TESTOUT 2>&1 << EOMODS2
116 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
119 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
123 # Try to modify the "ITD Staff" group. Two attempts are made:
124 # 1) bound as "James A Jones 1" - should fail
125 # 2) bound as "Bjorn Jensen" - should succeed
127 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
128 $TESTOUT 2>&1 << EOMODS3
130 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
136 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
137 $TESTOUT 2>&1 << EOMODS4
141 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
152 # Try to modify the "ITD Staff" group. Two attempts are made:
153 # 1) bound as "James A Jones 1" - should succeed
154 # 2) bound as "Barbara Jensen" - should fail
155 # should exploit sets
157 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
158 $TESTOUT 2>&1 << EOMODS5
159 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
162 description: added by jaj (should succeed)
166 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
167 $TESTOUT 2>&1 << EOMODS6
168 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
171 description: added by bjensen (should fail)
175 $LDAPMODIFY -D "$MANAGERDN" -h $LOCALHOST -p $PORT1 -w $PASSWD >> \
176 $TESTOUT 2>&1 << EOMODS7
177 dn: ou=Add/Delete,dc=example,dc=com
179 objectClass: organizationalUnit
183 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
184 $TESTOUT 2>&1 << EOMODS8
185 dn: cn=Added by Babs (must fail),ou=Add/Delete,dc=example,dc=com
187 objectClass: inetOrgPerson
188 cn: Added by Babs (must fail)
192 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
193 $TESTOUT 2>&1 << EOMODS9
194 dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com
196 objectClass: inetOrgPerson
197 cn: Added by Bjorn (must succeed)
200 dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com
202 objectClass: inetOrgPerson
203 cn: Added by Bjorn (will be deleted)
206 dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com
208 objectClass: inetOrgPerson
209 cn: Added by Bjorn (will be renamed)
212 dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com
215 description: this attribute value has been added __after__entry creation
216 description: this attribute value will be deleted by Babs (must succeed)
217 description: Bjorn will try to delete this attribute value (should fail)
221 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
222 $TESTOUT 2>&1 << EOMODS10
223 dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com
227 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
228 $TESTOUT 2>&1 << EOMODS11
229 dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com
231 newrdn: cn=Added by Bjorn (renamed by Bjorn)
235 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
236 $TESTOUT 2>&1 << EOMODS12
237 dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com
239 newrdn: cn=Added by Bjorn (renamed by Babs)
243 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
244 $TESTOUT 2>&1 << EOMODS13
245 dn: cn=Added by Bjorn (will be renamed),ou=Add/Delete,dc=example,dc=com
247 newrdn: cn=Added by Bjorn (renamed by Jaj)
251 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
252 $TESTOUT 2>&1 << EOMODS14
253 dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com
256 description: Bjorn will try to delete this attribute value (should fail)
260 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
261 $TESTOUT 2>&1 << EOMODS15
262 dn: cn=Added by Bjorn (will be deleted),ou=Add/Delete,dc=example,dc=com
265 dn: cn=Added by Bjorn (must succeed),ou=Add/Delete,dc=example,dc=com
268 description: this attribute value will be deleted by Babs (must succeed)
272 echo "Using ldapsearch to retrieve all the entries..."
273 echo "# Using ldapsearch to retrieve all the entries..." >> $SEARCHOUT
274 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
275 'objectClass=*' >> $SEARCHOUT 2>&1
277 test $KILLSERVERS != no && kill -HUP $KILLPIDS
278 if test $RC != 0 ; then
279 echo "ldapsearch failed ($RC)!"
285 echo "Filtering ldapsearch results..."
286 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
287 echo "Filtering original ldif used to create database..."
288 . $LDIFFILTER < $LDIF > $LDIFFLT
289 echo "Comparing filter output..."
290 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
292 if test $? != 0 ; then
293 echo "comparison failed - operations did not complete correctly"
297 echo ">>>>> Test succeeded"