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
77 echo "Using ldapsearch to check that slapd is running..."
78 for i in 0 1 2 3 4 5; do
79 $LDAPSEARCH -s base -b "$MONITOR" -h $LOCALHOST -p $PORT1 \
80 'objectclass=*' > /dev/null 2>&1
82 if test $RC = 0 ; then
85 echo "Waiting 5 seconds for slapd to start..."
89 echo "Testing ldapwhoami as proxy US..."
90 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy
92 if test $RC != 0 ; then
93 echo "ldapwhoami failed ($RC)!"
94 test $KILLSERVERS != no && kill -HUP $KILLPIDS
99 echo "Testing ldapwhoami as proxy US, $AUTHZID..."
100 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
102 if test $RC != 0 ; then
103 echo "ldapwhoami failed ($RC)!"
104 test $KILLSERVERS != no && kill -HUP $KILLPIDS
109 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
110 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
112 if test $RC != 1 ; then
113 echo "ldapwhoami should have failed ($RC)!"
114 test $KILLSERVERS != no && kill -HUP $KILLPIDS
119 echo "Testing ldapwhoami as proxy US, $AUTHZID... (should fail)"
120 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy US,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
122 if test $RC != 1 ; then
123 echo "ldapwhoami should have failed ($RC)!"
124 test $KILLSERVERS != no && kill -HUP $KILLPIDS
128 echo "Testing ldapwhoami as proxy IT..."
129 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy
131 if test $RC != 0 ; then
132 echo "ldapwhoami failed ($RC)!"
133 test $KILLSERVERS != no && kill -HUP $KILLPIDS
138 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
139 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
141 if test $RC != 1 ; then
142 echo "ldapwhoami should have failed ($RC)!"
143 test $KILLSERVERS != no && kill -HUP $KILLPIDS
148 echo "Testing ldapwhoami as proxy IT, $AUTHZID... (should fail)"
149 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
151 if test $RC != 1 ; then
152 echo "ldapwhoami should have failed ($RC)!"
153 test $KILLSERVERS != no && kill -HUP $KILLPIDS
157 AUTHZID="dn:cn=Sandbox,ou=Admin,dc=example,dc=com"
158 echo "Testing ldapwhoami as proxy IT, $AUTHZID..."
159 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "cn=proxy IT,ou=Admin,dc=example,dc=com" -w proxy -e\!"authzid=$AUTHZID"
161 if test $RC != 0 ; then
162 echo "ldapwhoami failed ($RC)!"
163 test $KILLSERVERS != no && kill -HUP $KILLPIDS
167 AUTHZID="dn:uid=bjorn,ou=People,o=Example,c=US"
168 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
169 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
171 if test $RC != 0 ; then
172 echo "ldapwhoami failed ($RC)!"
173 test $KILLSERVERS != no && kill -HUP $KILLPIDS
177 AUTHZID="dn:uid=bjorn,ou=People,o=Esempio,c=IT"
178 echo "Testing ldapwhoami as bjorn, $AUTHZID..."
179 $LDAPWHOAMI -h $LOCALHOST -p $PORT1 -D "uid=bjorn,ou=people,dc=example,dc=com" -w bjorn -e\!"authzid=$AUTHZID"
181 if test $RC != 0 ; then
182 echo "ldapwhoami failed ($RC)!"
183 test $KILLSERVERS != no && kill -HUP $KILLPIDS
187 ID="uid=jaj,ou=People,dc=example,dc=it"
188 BASE="o=Example,c=US"
189 echo "Testing ldapsearch as $ID for \"$BASE\"..."
190 $LDAPSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
191 -D "$ID" -w jaj > $SEARCHOUT 2>&1
194 if test $RC != 0 ; then
195 echo "ldapsearch failed ($RC)!"
196 test $KILLSERVERS != no && kill -HUP $KILLPIDS
200 echo "Filtering ldapsearch results..."
201 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
202 echo "Filtering original ldif used to create database..."
203 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
204 echo "Comparing filter output..."
205 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
207 if test $? != 0 ; then
208 echo "comparison failed - search with identity assertion didn't succeed"
209 test $KILLSERVERS != no && kill -HUP $KILLPIDS
213 if test $USE_SASL != "no" ; then
215 BASE="o=Example,c=US"
216 echo "Testing ldapsearch as $ID for \"$BASE\" with SASL bind and identity assertion..."
217 $LDAPSASLSEARCH -h $LOCALHOST -p $PORT1 -b "$BASE" \
218 -Q -U "$ID" -w jaj -Y $MECH > $SEARCHOUT 2>&1
221 if test $RC != 0 ; then
222 echo "ldapsearch failed ($RC)!"
223 test $KILLSERVERS != no && kill -HUP $KILLPIDS
227 echo "Filtering ldapsearch results..."
228 . $LDIFFILTER < $SEARCHOUT > $SEARCHFLT
229 echo "Filtering original ldif used to create database..."
230 . $LDIFFILTER < $IDASSERTOUT > $LDIFFLT
231 echo "Comparing filter output..."
232 $CMP $SEARCHFLT $LDIFFLT > $CMPOUT
234 if test $? != 0 ; then
235 echo "comparison failed - search with SASL bind and identity assertion didn't succeed"
236 test $KILLSERVERS != no && kill -HUP $KILLPIDS
241 test $KILLSERVERS != no && kill -HUP $KILLPIDS
243 echo ">>>>> Test succeeded"