squid authentication programme against directory server
-------------------------------------------------------
[root@eclectic bin]# pwd
/usr/local/squid/bin
[root@eclectic bin]# cat squid_auth_ldap.sh
#!/bin/sh
#
# Simple squid authenticator
#
LDAPSEARCH="/servers/netscape/directory416/bin/ldapsearch"
BASE="ou=People,o=The University of Macquarie,c=AU"
SERVER="directory.unimacq.edu.au"
LD_LIBRARY_PATH=/servers/netscape/directory416/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
while read username password
do
# echo $username
# echo $password
if 2>/dev/null >/dev/null grep $username /usr/local/squid/etc/squid-users
then
if 2>/dev/null >/dev/null $LDAPSEARCH -h "$SERVER" \
-b "$BASE" \
-D "uid=$username,$BASE" \
-w "$password" \
"(uid=$usernamee)"
then
echo OK
else
echo ERR
fi
else
echo ERR
fi
done
[root@eclectic bin]# cat /usr/local/squid/etc/squid-users
terrence davm
|