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 echo "### This test requires 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 "### with \"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 $RWM = rwmno ; then
31 echo "Rewrite/remap overlay not available, test skipped"
35 if test $WITH_SASL = "yes" ; then
36 if test $USE_SASL != "no" ; then
37 if test $USE_SASL = "yes" ; then
42 echo "Using SASL authc[/authz] with mech=$MECH; unset SLAPD_USE_SASL to disable"
44 echo "Using proxyAuthz with simple authc..."
47 echo "SASL not available; using proxyAuthz with simple authc..."
50 mkdir -p $TESTDIR $DBDIR1 $DBDIR2
52 echo "Running slapadd to build slapd database..."
53 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $ADDCONF
54 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT1 -n 1
56 if test $RC != 0 ; then
57 echo "slapadd -n 1 failed ($RC)!"
60 $SLAPADD -f $ADDCONF -l $LDIFIDASSERT2 -n 2
62 if test $RC != 0 ; then
63 echo "slapadd -n 2 failed ($RC)!"
67 echo "Starting slapd on TCP/IP port $PORT..."
68 . $CONFFILTER $BACKEND $MONITORDB < $IDASSERTCONF > $CONF1
69 $SLAPD -f $CONF1 -h $URI1 -d $LVL $TIMING > $LOG1 2>&1 &
71 if test $WAIT != 0 ; then
79 echo "Using ldapsearch to check that slapd is running..."
80 for i in 0 1 2 3 4 5; do
81 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
82 'objectclass=*' > /dev/null 2>&1
84 if test $RC = 0 ; then
87 echo "Waiting 5 seconds for slapd to start..."
91 echo "Testing ldapwhoami as proxy US..."
92 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
94 if test $RC != 0 ; then
95 echo "ldapwhoami failed ($RC)!"
96 test $KILLSERVERS != no && kill -HUP $KILLPIDS
101 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
102 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
104 if test $RC != 0 ; then
105 echo "ldapwhoami failed ($RC)!"
106 test $KILLSERVERS != no && kill -HUP $KILLPIDS
111 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
112 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
114 if test $RC != 1 ; then
115 echo "ldapwhoami should have failed ($RC)!"
116 test $KILLSERVERS != no && kill -HUP $KILLPIDS
121 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
122 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
124 if test $RC != 1 ; then
125 echo "ldapwhoami should have failed ($RC)!"
126 test $KILLSERVERS != no && kill -HUP $KILLPIDS
130 echo "Testing ldapwhoami as proxy IT..."
131 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
133 if test $RC != 0 ; then
134 echo "ldapwhoami failed ($RC)!"
135 test $KILLSERVERS != no && kill -HUP $KILLPIDS
140 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
141 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
143 if test $RC != 1 ; then
144 echo "ldapwhoami should have failed ($RC)!"
145 test $KILLSERVERS != no && kill -HUP $KILLPIDS
150 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
151 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
153 if test $RC != 1 ; then
154 echo "ldapwhoami should have failed ($RC)!"
155 test $KILLSERVERS != no && kill -HUP $KILLPIDS
159 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
160 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
161 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
163 if test $RC != 0 ; then
164 echo "ldapwhoami failed ($RC)!"
165 test $KILLSERVERS != no && kill -HUP $KILLPIDS
169 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
170 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
171 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
173 if test $RC != 0 ; then
174 echo "ldapwhoami failed ($RC)!"
175 test $KILLSERVERS != no && kill -HUP $KILLPIDS
179 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
180 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
181 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
183 if test $RC != 0 ; then
184 echo "ldapwhoami failed ($RC)!"
185 test $KILLSERVERS != no && kill -HUP $KILLPIDS
189 ID="uid=jaj,ou=People,dc=example,dc=it"
190 BASE="o=Example,c=US"
191 echo "Testing ldapsearch as $ID for \"$BASE\"..."
192 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
193 -D "$ID" -w jaj > $SEARCHOUT 2>&1
196 if test $RC != 0 ; then
197 echo "ldapsearch failed ($RC)!"
198 test $KILLSERVERS != no && kill -HUP $KILLPIDS
202 echo "Filtering ldapsearch results..."
203 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
204 echo "Filtering original ldif used to create database..."
205 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
206 echo "Comparing filter output..."
207 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
209 if test $? != 0 ; then
210 echo "comparison failed - search with identity assertion didn't succeed"
211 test $KILLSERVERS != no && kill -HUP $KILLPIDS
215 if test $USE_SASL != "no" ; then
217 BASE="o=Example,c=US"
218 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
219 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
220 -Q -U "$ID" -w jaj -Y $MECH > $SEARCHOUT 2>&1
223 if test $RC != 0 ; then
224 echo "ldapsearch failed ($RC)!"
225 test $KILLSERVERS != no && kill -HUP $KILLPIDS
229 echo "Filtering ldapsearch results..."
230 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
231 echo "Filtering original ldif used to create database..."
232 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
233 echo "Comparing filter output..."
234 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
236 if test $? != 0 ; then
237 echo "comparison failed - search with SASL bind and identity assertion didn't succeed"
238 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243 test $KILLSERVERS != no && kill -HUP $KILLPIDS
245 echo ">>>>> Test succeeded"