Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2465 → Rev 2466

/scripts/alcasar-ldap.sh
8,10 → 8,7
# enable / disable authentication of users via an extern LDAP server
 
# TODO
# - modif files "site-enabled/alcasar" + "mods-available/ldap"
# - add / remove "ln -s mods-available/ldap mods-enabled/ldap"
# - /usr/local/bin/alcasar-iptables.sh");
# - /usr/bin/systemctl restart radiusd");
# - modif files "site-enabled/alcasar"
 
# Modif "sites-enabled/alcasar"
# Configure autorize section with:
23,26 → 20,16
# ldap
# }
 
# Modif "mods-available/ldap"
# host = $ldap_server;
# identity = $ldap_user;
# password = $ldap_password;
# basedn = $ldap_base_dn;
# filter = $ldap_filter;
# uid = $ldap_filter;
# base_filter = $ldap_base_filter;
 
usage="Usage: alcasar-ldap.sh {--on or -on } | {--off or -off}"
SED="/bin/sed -i"
CONF_FILE="/usr/local/etc/alcasar.conf"
LDAP_MODULE="/etc/raddb/mods-available/ldap-alcasar"
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2` # INTernal InterFace
LDAP_SERVER=`grep ^LDAP_SERVER= $CONF_FILE|cut -d"=" -f2`
LDAP_BASE=`grep ^LDAP_BASE= $CONF_FILE|cut -d"=" -f2`
LDAP_UID=`grep ^LDAP_UID= $CONF_FILE|cut -d"=" -f2`
LDAP_FILTER=`grep ^LDAP_FILTER= $CONF_FILE|cut -d"=" -f2`
LDAP_USER=`grep ^LDAP_USER= $CONF_FILE|cut -d"=" -f2`
LDAP_PASSWORD=`grep ^LDAP_PASSWORD= $CONF_FILE|cut -d"=" -f2`
LDAP_SERVER=`grep ^LDAP_SERVER= $CONF_FILE|cut -d"=" -f2` # IP address of the LDAP server
LDAP_BASE=`grep ^LDAP_BASE= $CONF_FILE|cut -d"=" -f2-` # Where to find the users (cn=**,dc=**,dc=**)
LDAP_UID=`grep ^LDAP_UID= $CONF_FILE|cut -d"=" -f2` # 'samaccuntname' for A.D. - 'UID' for LDAP
LDAP_FILTER=`grep ^LDAP_FILTER= $CONF_FILE|cut -d"=" -f2` # Filter to limit users search (not used for now)
LDAP_USER=`grep ^LDAP_USER= $CONF_FILE|cut -d"=" -f2` # User name enable to list the directory
LDAP_PASSWORD=`grep ^LDAP_PASSWORD= $CONF_FILE|cut -d"=" -f2` #
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
57,17 → 44,22
;;
--on | -on)
$SED "s/^LDAP=.*/LDAP=on/g" $CONF_FILE
$SED "s/^server =.*/server = ldap://$LDAP_SERVER/g" $LDAP_MODULE
$SED "s/^identity =.*/identity = $LDAP_UID/g" $LDAP_MODULE
$SED "s/^server =.*/server = ldap:\/\/$LDAP_SERVER/g" $LDAP_MODULE
$SED "s/^identity =.*/identity = $LDAP_USER/g" $LDAP_MODULE
$SED "s/^password =.*/password = $LDAP_PASSWORD/g" $LDAP_MODULE
$SED "s/^base_dn =.*/base_dn = $LDAP_BASE/g" $LDAP_MODULE
$SED "s/^filter =.*/filter = ($LDAP_UID=%{%{Stripped-User-Name}:-%{User-Name}})/g" $LDAP_MODULE
ln -s $LDAP_MODULE /etc/raddb/mods-enabled/ldap
if [ ! -e /etc/raddb/mods-enabled/ldap ]
then
ln -s $LDAP_MODULE /etc/raddb/mods-enabled/ldap
fi
/usr/local/bin/alcasar-iptables.sh
/usr/bin/systemctl restart radiusd.service
;;
--off | -off)
$SED "s/^LDAP=.*/LDAP=off/g" $CONF_FILE
rm -f /etc/raddb/mods-enabled/ldap
/usr/local/bin/alcasar-iptables.sh
/usr/bin/systemctl restart radiusd.service
;;
*)