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
60 # Try to read an entry inside the Alumni Association container. It should
61 # give us nothing if we're not bound, and should return all attributes
62 # if we're bound as anyone under UM.
64 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 "objectclass=*" \
67 $LDAPSEARCH -b "$JAJDN" -h $LOCALHOST -p $PORT1 \
68 -D "$BABSDN" -w bjensen "objectclass=*" >> $SEARCHOUT 2>&1
71 # Check group access. Try to modify Babs' entry. Two attempts:
72 # 1) bound as "James A Jones 1" - should fail
73 # 2) bound as "Bjorn Jensen" - should succeed
75 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
76 $TESTOUT 2>&1 << EOMODS5
85 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
86 $TESTOUT 2>&1 << EOMODS6
90 homephone: +1 313 555 5444
95 # Try to add a "member" attribute to the "ITD Staff" group. It should
96 # fail when we add some DN other than our own, and should succeed when
99 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj > \
100 $TESTOUT 2>&1 << EOMODS1
102 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
105 uniquemember: cn=Barbara Jensen,ou=Information Technology Division,ou=People,dc=example,dc=com
109 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
110 $TESTOUT 2>&1 << EOMODS2
113 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
116 uniquemember: cn=James A Jones 1, ou=Alumni Association, ou=People, dc=example, dc=com
120 # Try to modify the "ITD Staff" group. Two attempts are made:
121 # 1) bound as "James A Jones 1" - should fail
122 # 2) bound as "Bjorn Jensen" - should succeed
124 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
125 $TESTOUT 2>&1 << EOMODS3
127 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
133 $LDAPMODIFY -D "$BJORNSDN" -h $LOCALHOST -p $PORT1 -w bjorn >> \
134 $TESTOUT 2>&1 << EOMODS4
138 dn: cn=ITD Staff, ou=Groups, dc=example, dc=com
149 # Try to modify the "ITD Staff" group. Two attempts are made:
150 # 1) bound as "James A Jones 1" - should succeed
151 # 2) bound as "Barbara Jensen" - should fail
152 # should exploit sets
154 $LDAPMODIFY -D "$JAJDN" -h $LOCALHOST -p $PORT1 -w jaj >> \
155 $TESTOUT 2>&1 << EOMODS5
156 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
159 description: added by jaj (should succeed)
163 $LDAPMODIFY -D "$BABSDN" -h $LOCALHOST -p $PORT1 -w bjensen >> \
164 $TESTOUT 2>&1 << EOMODS6
165 dn: cn=Alumni Assoc Staff, ou=Groups, dc=example, dc=com
168 description: added by bjensen (should fail)
172 echo "Using ldapsearch to retrieve all the entries..."
173 $LDAPSEARCH -S "" -b "$BASEDN" -h $LOCALHOST -p $PORT1 \
174 'objectClass=*' >> $SEARCHOUT 2>&1
176 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 if test $RC != 0 ; then
178 echo "ldapsearch failed ($RC)!"
184 echo "Filtering ldapsearch results..."
185 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
186 echo "Filtering original ldif used to create database..."
187 . $LDIFFILTER < $LDIF > $LDIFFLT
188 echo "Comparing filter output..."
189 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
191 if test $? != 0 ; then
192 echo "comparison failed - modify operations did not complete correctly"
196 echo ">>>>> Test succeeded"