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