Line 57... |
Line 57... |
57 |
}
|
57 |
}
|
58 |
if (!is_writable(ALCASAR_RADIUS_MODULE_LDAP)){
|
58 |
if (!is_writable(ALCASAR_RADIUS_MODULE_LDAP)){
|
59 |
exit("Vous n'avez pas les droits d'écriture sur le fichier /etc/raddb/mods-available/ldap");
|
59 |
exit("Vous n'avez pas les droits d'écriture sur le fichier /etc/raddb/mods-available/ldap");
|
60 |
}
|
60 |
}
|
61 |
|
61 |
|
62 |
/****************************************************************
|
- |
|
63 |
* File sites-enabled/alcasar *
|
- |
|
64 |
*****************************************************************/
|
- |
|
65 |
/*
|
- |
|
66 |
ON ACTIVE LE LDAP
|
- |
|
67 |
*/
|
- |
|
68 |
/*
|
- |
|
69 |
Configure autorize section with:
|
- |
|
70 |
ldap {
|
- |
|
71 |
fail=1
|
- |
|
72 |
}
|
- |
|
73 |
*/
|
- |
|
74 |
/*
|
- |
|
75 |
Configure authenticate section with
|
- |
|
76 |
Auth-Type LDAP {
|
- |
|
77 |
ldap
|
- |
|
78 |
}
|
- |
|
79 |
*/
|
- |
|
80 |
/*
|
- |
|
81 |
|
- |
|
82 |
/****************************************************************
|
- |
|
83 |
* File mods/available/ldap *
|
- |
|
84 |
*****************************************************************/
|
- |
|
85 |
//$ldap->host = $ldap_server;
|
- |
|
86 |
//$ldap->identity = $ldap_user;
|
- |
|
87 |
//$ldap->password = $ldap_password;
|
- |
|
88 |
//$ldap->basedn = $ldap_base_dn;
|
- |
|
89 |
//$ldap->filter = $ldap_filter;
|
- |
|
90 |
//$ldap->uid = $ldap_filter;
|
- |
|
91 |
//$ldap->base_filter = $ldap_base_filter;
|
- |
|
92 |
|
- |
|
93 |
/********************************************************
|
62 |
/********************************************************
|
94 |
* File modification & services restart *
|
63 |
* Conf file modification & ldap script call *
|
95 |
*********************************************************/
|
64 |
*********************************************************/
|
96 |
//test d'accès au serveur
|
- |
|
97 |
//si réussite
|
- |
|
98 |
// - écriture config ldap complète dans alcasar.conf
|
- |
|
99 |
// - appel script-shell (alcasar-ldap.sh)
|
- |
|
100 |
// - modif des 2 fichier ci-dessus
|
65 |
// After testing serveur access
|
101 |
// - actions si dessous
|
- |
|
102 |
if ($auth_enable == "1") {
|
66 |
if ($auth_enable == "1") {
|
- |
|
67 |
exec("sed -i \"s/^LDAP=.*/LDAP=on/g\" ".ALCASAR_CONF_FILE);
|
103 |
file_put_contents(ALCASAR_CONF_FILE, str_replace('LDAP=off', 'LDAP=on', file_get_contents(ALCASAR_CONF_FILE)));
|
68 |
exec("sed -i \"s/^LDAP_SERVER=.*/LDAP_SERVER=$ldap_server/g\" ".ALCASAR_CONF_FILE);
|
- |
|
69 |
exec("sed -i \"s/^LDAP_BASE=.*/LDAP_BASE=$ldap_base_dn/g\" ".ALCASAR_CONF_FILE);
|
104 |
exec("sed -i \"s/^LDAP_IP=.*/LDAP_IP=$ldap_server/g\" ".ALCASAR_CONF_FILE);
|
70 |
exec("sed -i \"s/^LDAP_UID=.*/LDAP_UID=$ldap_filter/g\" ".ALCASAR_CONF_FILE);
|
- |
|
71 |
exec("sed -i \"s/^LDAP_FILTER=.*/LDAP_FILTER=$ldap_filter/g\" ".ALCASAR_CONF_FILE);
|
105 |
exec("ln -s /etc/raddb/mods-available/ldap /etc/raddb/mods-enabled/ldap");
|
72 |
exec("sed -i \"s/^LDAP_USER=.*/LDAP_USER=$ldap_user/g\" ".ALCASAR_CONF_FILE);
|
- |
|
73 |
exec("sed -i \"s/^LDAP_PASSWORD=.*/LDAP_PASSWORD=$ldap_password/g\" ".ALCASAR_CONF_FILE);
|
- |
|
74 |
exec("sudo /usr/local/bin/alcasar-ldap.sh -on");
|
106 |
}
|
75 |
}
|
107 |
else {
|
76 |
else {
|
108 |
file_put_contents(ALCASAR_CONF_FILE, str_replace('LDAP=on', 'LDAP=off', file_get_contents(ALCASAR_CONF_FILE)));
|
- |
|
109 |
exec("sed -i \"s/^LDAP_IP=.*/LDAP_IP=0.0.0.0/g\" ".ALCASAR_CONF_FILE);
|
77 |
exec("sed -i \"s/^LDAP=.*/LDAP=off/g\" ".ALCASAR_CONF_FILE);
|
110 |
exec("rm -f /etc/raddb/mods-enabled/ldap");
|
78 |
exec("sudo /usr/local/bin/alcasar-ldap.sh -off");
|
111 |
}
|
79 |
}
|
112 |
#exec("sudo /usr/local/bin/alcasar-iptables.sh");
|
- |
|
113 |
#exec("sudo /usr/bin/systemctl restart radiusd");
|
- |
|
114 |
|
80 |
|
115 |
/****************************************************************
|
81 |
/****************************************************************
|
116 |
* Redirection vers la page de configuration LDAP *
|
82 |
* Redirection vers la page de configuration LDAP *
|
117 |
*****************************************************************/
|
83 |
*****************************************************************/
|
118 |
|
84 |
|