Subversion Repositories ALCASAR

Rev

Rev 2465 | Rev 2467 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2465 Rev 2466
Line 6... Line 6...
6
 
6
 
7
# activation / désactivation de l'authentification des utilisateurs via un serveur LDAP externe
7
# activation / désactivation de l'authentification des utilisateurs via un serveur LDAP externe
8
# enable / disable authentication of users via an extern LDAP server
8
# enable / disable authentication of users via an extern LDAP server
9
 
9
 
10
# TODO
10
# TODO
11
#		- modif files "site-enabled/alcasar" + "mods-available/ldap"
11
#	- modif files "site-enabled/alcasar"
12
#		- add / remove "ln -s mods-available/ldap mods-enabled/ldap"
-
 
13
#       - /usr/local/bin/alcasar-iptables.sh");
-
 
14
#       - /usr/bin/systemctl restart radiusd");
-
 
15
 
12
 
16
# Modif "sites-enabled/alcasar"
13
# Modif "sites-enabled/alcasar"
17
#	Configure autorize section with:
14
#	Configure autorize section with:
18
#		ldap  { 
15
#		ldap  { 
19
#			fail=1
16
#			fail=1
Line 21... Line 18...
21
#	Configure authenticate section with
18
#	Configure authenticate section with
22
#		Auth-Type LDAP {
19
#		Auth-Type LDAP {
23
#			ldap
20
#			ldap
24
#		}
21
#		}
25
 
22
 
26
# Modif "mods-available/ldap"
-
 
27
#	host = $ldap_server;
-
 
28
#	identity = $ldap_user;
-
 
29
#	password = $ldap_password;
-
 
30
#	basedn = $ldap_base_dn;
-
 
31
#	filter = $ldap_filter;
-
 
32
#	uid = $ldap_filter;
-
 
33
#	base_filter = $ldap_base_filter;
-
 
34
 
-
 
35
usage="Usage: alcasar-ldap.sh {--on or -on } | {--off or -off}"
23
usage="Usage: alcasar-ldap.sh {--on or -on } | {--off or -off}"
36
SED="/bin/sed -i"
24
SED="/bin/sed -i"
37
CONF_FILE="/usr/local/etc/alcasar.conf"
25
CONF_FILE="/usr/local/etc/alcasar.conf"
38
LDAP_MODULE="/etc/raddb/mods-available/ldap-alcasar"
26
LDAP_MODULE="/etc/raddb/mods-available/ldap-alcasar"
39
INTIF=`grep ^INTIF= $CONF_FILE|cut -d"=" -f2`				# INTernal InterFace
-
 
40
LDAP_SERVER=`grep ^LDAP_SERVER= $CONF_FILE|cut -d"=" -f2`
27
LDAP_SERVER=`grep ^LDAP_SERVER= $CONF_FILE|cut -d"=" -f2`	# IP address of the LDAP server
41
LDAP_BASE=`grep ^LDAP_BASE= $CONF_FILE|cut -d"=" -f2`
28
LDAP_BASE=`grep ^LDAP_BASE= $CONF_FILE|cut -d"=" -f2-`		# Where to find the users (cn=**,dc=**,dc=**)
42
LDAP_UID=`grep ^LDAP_UID= $CONF_FILE|cut -d"=" -f2`
29
LDAP_UID=`grep ^LDAP_UID= $CONF_FILE|cut -d"=" -f2`		# 'samaccuntname' for A.D. - 'UID' for LDAP
43
LDAP_FILTER=`grep ^LDAP_FILTER= $CONF_FILE|cut -d"=" -f2`
30
LDAP_FILTER=`grep ^LDAP_FILTER= $CONF_FILE|cut -d"=" -f2`	# Filter to limit users search (not used for now)
44
LDAP_USER=`grep ^LDAP_USER= $CONF_FILE|cut -d"=" -f2`
31
LDAP_USER=`grep ^LDAP_USER= $CONF_FILE|cut -d"=" -f2`		# User name enable to list the directory
45
LDAP_PASSWORD=`grep ^LDAP_PASSWORD= $CONF_FILE|cut -d"=" -f2`
32
LDAP_PASSWORD=`grep ^LDAP_PASSWORD= $CONF_FILE|cut -d"=" -f2`	#
46
nb_args=$#
33
nb_args=$#
47
args=$1
34
args=$1
48
if [ $nb_args -eq 0 ]
35
if [ $nb_args -eq 0 ]
49
then
36
then
50
	nb_args=1
37
	nb_args=1
Line 55... Line 42...
55
		echo "$usage"
42
		echo "$usage"
56
		exit 0
43
		exit 0
57
		;;
44
		;;
58
	--on | -on)	
45
	--on | -on)	
59
		$SED "s/^LDAP=.*/LDAP=on/g" $CONF_FILE
46
		$SED "s/^LDAP=.*/LDAP=on/g" $CONF_FILE
60
		$SED "s/^server =.*/server = ldap://$LDAP_SERVER/g" $LDAP_MODULE
47
		$SED "s/^server =.*/server = ldap:\/\/$LDAP_SERVER/g" $LDAP_MODULE
61
		$SED "s/^identity =.*/identity = $LDAP_UID/g" $LDAP_MODULE
48
		$SED "s/^identity =.*/identity = $LDAP_USER/g" $LDAP_MODULE
62
		$SED "s/^password =.*/password = $LDAP_PASSWORD/g" $LDAP_MODULE
49
		$SED "s/^password =.*/password = $LDAP_PASSWORD/g" $LDAP_MODULE
63
		$SED "s/^base_dn =.*/base_dn = $LDAP_BASE/g" $LDAP_MODULE
50
		$SED "s/^base_dn =.*/base_dn = $LDAP_BASE/g" $LDAP_MODULE
64
		$SED "s/^filter =.*/filter = ($LDAP_UID=%{%{Stripped-User-Name}:-%{User-Name}})/g" $LDAP_MODULE
51
		$SED "s/^filter =.*/filter = ($LDAP_UID=%{%{Stripped-User-Name}:-%{User-Name}})/g" $LDAP_MODULE
-
 
52
		if [ ! -e /etc/raddb/mods-enabled/ldap ]
-
 
53
		then
65
		ln -s $LDAP_MODULE /etc/raddb/mods-enabled/ldap
54
			ln -s $LDAP_MODULE /etc/raddb/mods-enabled/ldap
-
 
55
		fi
-
 
56
		/usr/local/bin/alcasar-iptables.sh
66
		/usr/bin/systemctl restart radiusd.service
57
		/usr/bin/systemctl restart radiusd.service
67
		;;
58
		;;
68
	--off | -off)
59
	--off | -off)
69
		$SED "s/^LDAP=.*/LDAP=off/g" $CONF_FILE
60
		$SED "s/^LDAP=.*/LDAP=off/g" $CONF_FILE
70
		rm -f /etc/raddb/mods-enabled/ldap
61
		rm -f /etc/raddb/mods-enabled/ldap
-
 
62
		/usr/local/bin/alcasar-iptables.sh
71
		/usr/bin/systemctl restart radiusd.service
63
		/usr/bin/systemctl restart radiusd.service
72
;;
64
;;
73
	*)
65
	*)
74
		echo "Argument inconnu :$1";
66
		echo "Argument inconnu :$1";
75
		echo "$usage"
67
		echo "$usage"