]> git.sur5r.net Git - openldap/blob - tests/scripts/test006-acls
6979cf27fa8a1075472076d0e1497eac5af35545
[openldap] / tests / scripts / test006-acls
1 #!/bin/sh
2
3 if [ $# -eq 0 ]; then
4         SRCDIR="."
5 else
6         SRCDIR=$1; shift
7 fi
8
9 . $SRCDIR/scripts/defines.sh $SRCDIR
10
11 echo "Cleaning up in $DBDIR..."
12
13 rm -f $DBDIR/[!C]*
14
15 echo "Running ldif2ldbm to build slapd database..."
16 $LDIF2LDBM -f $CONF -i $LDIF -e ../servers/slapd/tools
17 RC=$?
18 if [ $RC != 0 ]; then
19         echo "ldif2ldbm failed!"
20         exit $RC
21 fi
22
23 echo "Starting slapd on TCP/IP port $PORT..."
24 $SLAPD -f $ACLCONF -p $PORT -d 1 > $MASTERLOG 2>&1 &
25 PID=$!
26
27 echo "Testing slapd access control..."
28 for i in 0 1 2 3 4 5; do
29         $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
30                 'cn=Monitor' > /dev/null 2>&1
31         RC=$?
32         if [ $RC = 1 ]; then
33                 echo "Waiting 5 seconds for slapd to start..."
34                 sleep 5
35         fi
36 done
37
38 if [ $RC != 0 ]; then
39         echo "ldapsearch failed!"
40         kill -HUP $PID
41         exit $RC
42 fi
43
44 cat /dev/null > $SEARCHOUT
45
46 #
47 # Try to read an entry inside the Alumni Association container.  It should
48 # give us nothing if we're not bound, and should return all attributes
49 # if we're bound as anyone under UM.
50 #
51 $LDAPSEARCH -L -b "$JAJDN" -h localhost -p $PORT "objectclass=*" \
52         >> $SEARCHOUT 2>&1
53
54 $LDAPSEARCH -L -b "$JAJDN" -h localhost -p $PORT \
55         -D "$BABSDN" -w bjensen "objectclass=*"  >> $SEARCHOUT 2>&1
56
57
58 #
59 # Try to add a "member" attribute to the "All Staff" group.  It should
60 # fail when we add some DN other than our own, and should succeed when
61 # we add our own DN.
62 # bjensen
63 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
64         /dev/null 2>&1 << EOMODS1
65 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
66 changetype: modify
67 add: member
68 member: cn=Barbara Jensen, ou=Information Technology Division, ou=People, o=University of Michigan, c=US
69
70 EOMODS1
71
72 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
73         /dev/null 2>&1 << EOMODS2
74 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
75 changetype: modify
76 add: member
77 member: cn=James A Jones 1, ou=Alumni Association, ou=People, o=University of Michigan, c=US
78
79 EOMODS2
80
81 #
82 # Try to modify the "All Staff" group.  Two attempts are made:
83 # 1) bound as "James A Jones 1" - should fail
84 # 2) bound as "Barbara Jensen" - should succeed
85 #
86 $LDAPMODIFY -D "$JAJDN" -h localhost -p $PORT -w jaj > \
87         /dev/null 2>&1 << EOMODS3
88 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
89 changetype: modify
90 delete: member
91
92 EOMODS3
93
94 $LDAPMODIFY -D "$BJORNSDN" -h localhost -p $PORT -w bjorn > \
95         /dev/null 2>&1 << EOMODS4
96 dn: cn=ITD Staff, ou=Groups, o=University of Michigan, c=US
97 changetype: modify
98 add: telephonenumber
99 telephonenumber: +1 810 555 1212
100
101 EOMODS4
102
103 echo "Using ldapsearch to retrieve all the entries..."
104 $LDAPSEARCH -L -S "" -b "$BASEDN" -h localhost -p $PORT \
105             'objectClass=*' | . $SRCDIR/scripts/acfilter.sh >> $SEARCHOUT 2>&1
106 RC=$?
107 kill -HUP $PID
108 if [ $RC != 0 ]; then
109         echo "ldapsearch failed!"
110         exit $RC
111 fi
112
113 echo "Comparing database to reference file"
114 cmp $SEARCHOUT $ACLOUTMASTER
115 if [ $? != 0 ]; then
116         echo "comparison failed - modify operations did not complete correctly"
117         exit 1
118 fi
119
120 echo ">>>>> Test succeeded"
121
122
123 exit 0