Subversion Repositories ALCASAR

Compare Revisions

Ignore whitespace Rev 2466 → Rev 2467

/scripts/alcasar-ldap.sh
7,29 → 7,16
# activation / désactivation de l'authentification des utilisateurs via un serveur LDAP externe
# enable / disable authentication of users via an extern LDAP server
 
# TODO
# - modif files "site-enabled/alcasar"
 
# Modif "sites-enabled/alcasar"
# Configure autorize section with:
# ldap {
# fail=1
# }
# Configure authenticate section with
# Auth-Type LDAP {
# ldap
# }
 
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"
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` #
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-` # LDAP username used by ALCASAR to read the remote directory
LDAP_PASSWORD=`grep ^LDAP_PASSWORD= $CONF_FILE|cut -d"=" -f2` # its password
nb_args=$#
args=$1
if [ $nb_args -eq 0 ]
47,12 → 34,17
$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
$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
if [ ! -e /etc/raddb/mods-enabled/ldap ]
then
ln -s $LDAP_MODULE /etc/raddb/mods-enabled/ldap
fi
if [ -e /etc/raddb/sites-enabled/alcasar ]
then
rm /etc/raddb/sites-enabled/alcasar
fi
ln -s /etc/raddb/sites-available/alcasar-with-ldap /etc/raddb/sites-enabled/alcasar
/usr/local/bin/alcasar-iptables.sh
/usr/bin/systemctl restart radiusd.service
;;
59,6 → 51,11
--off | -off)
$SED "s/^LDAP=.*/LDAP=off/g" $CONF_FILE
rm -f /etc/raddb/mods-enabled/ldap
if [ -e /etc/raddb/sites-enabled/alcasar ]
then
rm /etc/raddb/sites-enabled/alcasar
fi
ln -s /etc/raddb/sites-available/alcasar /etc/raddb/sites-enabled/alcasar
/usr/local/bin/alcasar-iptables.sh
/usr/bin/systemctl restart radiusd.service
;;