3 ## This work is part of OpenLDAP Software <http://www.openldap.org/>.
5 ## Copyright 1998-2004 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 echo "### This test needs the ldap backend."
20 echo "### If available, and explicitly requested, it can use SASL bind;"
21 echo "### note that SASL must be properly set up, and the requested"
22 echo "### mechanism must be available. Define SLAPD_USE_SASL={yes|<mech>},"
23 echo "### wth \"yes\" defaulting to DIGEST-MD5 to enable SASL authc[/authz]."
25 if test $BACKLDAP = "ldapno" ; then
26 echo "LDAP backend not available, test skipped"
30 if test $WITH_SASL = "yes" ; then
31 if test $USE_SASL != "no" ; then
32 if test $USE_SASL = "yes" ; then
37 echo "Using SASL authc[/authz] with mech=$MECH; unset SLAPD_USE_SASL to disable"
39 echo "Using proxyAuthz with simple authc..."
42 echo "SASL not available; using proxyAuthz with simple authc..."
45 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
47 echo "Running slapadd to build slapd database..."
48 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
49 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
51 if test $RC != 0 ; then
52 echo "slapadd -n 1 failed ($RC)!"
55 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
57 if test $RC != 0 ; then
58 echo "slapadd -n 2 failed ($RC)!"
62 echo "Starting slapd on TCP/IP port $PORT..."
63 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
64 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
66 if test $WAIT != 0 ; then
72 echo "Using ldapsearch to check that slapd is running..."
73 for i in 0 1 2 3 4 5; do
74 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
75 'objectclass=*' > /dev/null 2>&1
77 if test $RC = 0 ; then
80 echo "Waiting 5 seconds for slapd to start..."
84 echo "Testing ldapwhoami as proxy US..."
85 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
87 if test $RC != 0 ; then
88 echo "ldapwhoami failed ($RC)!"
89 test $KILLSERVERS != no && kill -HUP $KILLPIDS
94 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
95 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
97 if test $RC != 0 ; then
98 echo "ldapwhoami failed ($RC)!"
99 test $KILLSERVERS != no && kill -HUP $KILLPIDS
104 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
105 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
107 if test $RC != 1 ; then
108 echo "ldapwhoami should have failed ($RC)!"
109 test $KILLSERVERS != no && kill -HUP $KILLPIDS
114 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
115 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
117 if test $RC != 1 ; then
118 echo "ldapwhoami should have failed ($RC)!"
119 test $KILLSERVERS != no && kill -HUP $KILLPIDS
123 echo "Testing ldapwhoami as proxy IT..."
124 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
126 if test $RC != 0 ; then
127 echo "ldapwhoami failed ($RC)!"
128 test $KILLSERVERS != no && kill -HUP $KILLPIDS
133 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
134 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
136 if test $RC != 1 ; then
137 echo "ldapwhoami should have failed ($RC)!"
138 test $KILLSERVERS != no && kill -HUP $KILLPIDS
143 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
144 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
146 if test $RC != 1 ; then
147 echo "ldapwhoami should have failed ($RC)!"
148 test $KILLSERVERS != no && kill -HUP $KILLPIDS
152 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
153 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
154 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
156 if test $RC != 0 ; then
157 echo "ldapwhoami failed ($RC)!"
158 test $KILLSERVERS != no && kill -HUP $KILLPIDS
162 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
163 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
164 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
166 if test $RC != 0 ; then
167 echo "ldapwhoami failed ($RC)!"
168 test $KILLSERVERS != no && kill -HUP $KILLPIDS
172 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
173 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
174 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
176 if test $RC != 0 ; then
177 echo "ldapwhoami failed ($RC)!"
178 test $KILLSERVERS != no && kill -HUP $KILLPIDS
182 ID="uid=jaj,ou=People,dc=example,dc=it"
183 BASE="o=Example,c=US"
184 echo "Testing ldapsearch as $ID for \"$BASE\"..."
185 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
186 -D "$ID" -w jaj > $SEARCHOUT 2>&1
189 if test $RC != 0 ; then
190 echo "ldapsearch failed ($RC)!"
191 test $KILLSERVERS != no && kill -HUP $KILLPIDS
195 echo "Filtering ldapsearch results..."
196 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
197 echo "Filtering original ldif used to create database..."
198 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
199 echo "Comparing filter output..."
200 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
202 if test $? != 0 ; then
203 echo "comparison failed - search with identity assertion didn't succeed"
207 if test $USE_SASL != "no" ; then
209 BASE="o=Example,c=US"
210 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
211 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
212 -Q -U "$ID" -w jaj -Y $MECH > $SEARCHOUT 2>&1
215 if test $RC != 0 ; then
216 echo "ldapsearch failed ($RC)!"
217 test $KILLSERVERS != no && kill -HUP $KILLPIDS
221 echo "Filtering ldapsearch results..."
222 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
223 echo "Filtering original ldif used to create database..."
224 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
225 echo "Comparing filter output..."
226 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
228 if test $? != 0 ; then
229 echo "comparison failed - search with SASL bind and identity assertion didn't succeed"
234 test $KILLSERVERS != no && kill -HUP $KILLPIDS
236 echo ">>>>> Test succeeded"