1 |
<?php
|
1 |
<?php
|
2 |
require_once("lib/alcasar/freeradius/siteconfig.php");
|
2 |
require_once("lib/alcasar/freeradius/siteconfig.php");
|
3 |
require_once("lib/alcasar/freeradius/ldapconfig.php");
|
3 |
require_once("lib/alcasar/freeradius/ldapconfig.php");
|
4 |
|
4 |
|
5 |
/* written by steweb57 */
|
5 |
/* written by steweb57 */
|
6 |
/****************************************************************
|
6 |
/****************************************************************
|
7 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
7 |
* CONSTANTES AVEC CHEMINS DES FICHIERS DE CONFIGURATION *
|
8 |
*****************************************************************/
|
8 |
*****************************************************************/
|
9 |
|
9 |
|
10 |
define ("ALCASAR_RADIUS_SITE", "/etc/raddb/sites-available/alcasar");
|
10 |
define ("ALCASAR_RADIUS_SITE", "/etc/raddb/sites-available/alcasar");
|
11 |
define ("ALCASAR_RADIUS_MODULE_LDAP", "/etc/raddb/modules/ldap");
|
11 |
define ("ALCASAR_RADIUS_MODULE_LDAP", "/etc/raddb/modules/ldap");
|
12 |
|
12 |
|
- |
|
13 |
/****************************************************************
|
- |
|
14 |
* Choice of language *
|
- |
|
15 |
*****************************************************************/
|
- |
|
16 |
|
- |
|
17 |
$Language = 'en';
|
- |
|
18 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
- |
|
19 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
- |
|
20 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
- |
|
21 |
if($Language == 'fr'){
|
- |
|
22 |
$l_file = "Fichier ";
|
- |
|
23 |
$l_not_found = " non présent";
|
- |
|
24 |
$l_no_writing_right_on_file = "Vous n'avez pas les droits d'écriture sur le fichier ";
|
- |
|
25 |
$l_ldap_update_sucess = "Mise à jour des paramètres LDAP réalisée avec succès";
|
- |
|
26 |
$l_ldap_title = "Authentification externe : LDAP";
|
- |
|
27 |
$l_ldap_legend = "Authentification LDAP";
|
- |
|
28 |
$l_ldap_auth_enable_label = "Activer l'authentification LDAP:";
|
- |
|
29 |
$l_ldap_YES = "OUI";
|
- |
|
30 |
$l_ldap_NO = "NON";
|
- |
|
31 |
$l_ldap_server_label = "Nom du serveur LDAP:";
|
- |
|
32 |
$l_ldap_server_text = "Nom ou IP du serveur LDAP éventuel.";
|
- |
|
33 |
$l_ldap_base_dn_label = "DN de la base LDAP:";
|
- |
|
34 |
$l_ldap_base_dn_text = "DN est le 'Distinguished Name', il situe les informations utilisateurs, exemple: 'o=Mon entreprise, c=FR'.";
|
- |
|
35 |
$l_ldap_filter_label = "Identifiant LDAP:";
|
- |
|
36 |
$l_ldap_filter_text = "Clé utilisée pour la recherche d'un identifiant de connexion, exemple: 'uid', 'sn', etc. Pour un AD mettre 'sAMAccountName'.";
|
- |
|
37 |
$l_ldap_base_filter_label = "Filtre de l'utilisateur LDAP:";
|
- |
|
38 |
$l_ldap_base_filter_text = "Sur option, vous pouvez en plus limiter les objets recherchés avec des filtres additionnels. Par exemple 'objectClass=posixGroup' aurait comme conséquence l'utilisation de '(&(uid=username)(objectClass=posixGroup))'";
|
- |
|
39 |
$l_ldap_user_label = "Utilisateur LDAP:";
|
- |
|
40 |
$l_ldap_user_text = "Laissez vide pour utiliser un accès invité. Si renseigné, ALCASAR se connectera au serveur LDAP en tant qu'un utilisateur spécifié, exemple: 'uid=Utilisateur,ou=MonUnité,o=MaCompagnie,c=FR'. Requis pour les serveurs possédant un Active Directory.";
|
- |
|
41 |
$l_ldap_password_label = "Mot de passe LDAP:";
|
- |
|
42 |
$l_ldap_password_text = "Laissez vide pour un accès invité. Sinon, indiquez le mot de passe de connexion. Requis pour les serveurs possédant un Active Directory.";
|
- |
|
43 |
$l_ldap_submit = "Enregistrer";
|
- |
|
44 |
$l_ldap_reset = "Annuler";
|
- |
|
45 |
$l_ldap_test_network_failed = "Pas de connectivité réseau avec le serveur LDAP.";
|
- |
|
46 |
$l_ldap_test_connection_failed = "Impossible de se connecter au serveur LDAP.";
|
- |
|
47 |
$l_ldap_test_bind_ok = "Connexion LDAP réussie...";
|
- |
|
48 |
$l_ldap_test_bind_failed = "Echec d'authentification sur le serveur LDAP...Vérifiez votre configuration ldap...";
|
- |
|
49 |
} else {
|
- |
|
50 |
$l_file = "File ";
|
- |
|
51 |
$l_not_found = " not found";
|
- |
|
52 |
$l_no_writing_right_on_file = "You have no writting permission on the file ";
|
- |
|
53 |
$l_ldap_update_sucess = "Successfull LDAP settings update";
|
- |
|
54 |
$l_ldap_title = "External authentication : LDAP";
|
- |
|
55 |
$l_ldap_legend = "LDAP authentication";
|
- |
|
56 |
$l_ldap_auth_enable_label = "Use LDAP authentication :";
|
- |
|
57 |
$l_ldap_YES = "YES";
|
- |
|
58 |
$l_ldap_NO = "NO";
|
- |
|
59 |
$l_ldap_server_label = "LDAP server name:";
|
- |
|
60 |
$l_ldap_server_text = "This is the hostname or IP address of the LDAP server.";
|
- |
|
61 |
$l_ldap_base_dn_label = "LDAP base dn:";
|
- |
|
62 |
$l_ldap_base_dn_text = "This is the 'Distinguished Name', locating the user information, e.g. 'o=My Company,c=US'.";
|
- |
|
63 |
$l_ldap_filter_label = "LDAP uid:";
|
- |
|
64 |
$l_ldap_filter_text = "This is the key under which to search for a given login identity, e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
|
- |
|
65 |
$l_ldap_base_filter_label = "LDAP user filter:";
|
- |
|
66 |
$l_ldap_base_filter_text = "Optionally you can further limit the searched objects with additional filters. For example 'objectClass=posixGroup' would result in the use of '(&(uid=username)(objectClass=posixGroup))'";
|
- |
|
67 |
$l_ldap_user_label = "LDAP user dn:";
|
- |
|
68 |
$l_ldap_user_text = "Leave blank to use anonymous binding. If filled, ALCASAR uses the specified distinguished name on login attempts to find the correct user, e.g. 'uid=Username,ou=MyUnit,o=MyCompany,c=US'. Required for Active Directory Servers.";
|
- |
|
69 |
$l_ldap_password_label = "LDAP password:";
|
- |
|
70 |
$l_ldap_password_text = "Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.";
|
- |
|
71 |
$l_ldap_submit = "Save";
|
- |
|
72 |
$l_ldap_reset = "Reset";
|
- |
|
73 |
$l_ldap_test_network_failed = "LDAP server is not reachable.";
|
- |
|
74 |
$l_ldap_test_connection_failed = "LDAP connexion failed...";
|
- |
|
75 |
$l_ldap_test_bind_ok = "LDAP connexion success...";
|
- |
|
76 |
$l_ldap_test_bind_failed = "LDAP authentication failed...Check your ldap setup...";
|
- |
|
77 |
}
|
13 |
/********************************************************
|
78 |
/********************************************************
|
14 |
* TEST DES FICHIERS DE CONFIGURATION *
|
79 |
* TEST DES FICHIERS DE CONFIGURATION *
|
15 |
*********************************************************/
|
80 |
*********************************************************/
|
16 |
|
81 |
|
17 |
//Test de présence et des droits en lecture des fichiers de configuration.
|
82 |
//Test de présence et des droits en lecture des fichiers de configuration.
|
18 |
if (!file_exists(ALCASAR_RADIUS_SITE)){
|
83 |
if (!file_exists(ALCASAR_RADIUS_SITE)){
|
19 |
exit("Fichier ".ALCASAR_RADIUS_SITE." non présent");
|
84 |
exit($l_file.ALCASAR_RADIUS_SITE.$l_not_found);
|
20 |
}
|
85 |
}
|
21 |
if (!file_exists(ALCASAR_RADIUS_MODULE_LDAP)){
|
86 |
if (!file_exists(ALCASAR_RADIUS_MODULE_LDAP)){
|
22 |
exit("Fichier ".ALCASAR_RADIUS_MODULE_LDAP." non présent");
|
87 |
exit($l_file.ALCASAR_RADIUS_MODULE_LDAP.$l_not_found);
|
23 |
}
|
88 |
}
|
24 |
if (!is_readable(ALCASAR_RADIUS_SITE)){
|
89 |
if (!is_readable(ALCASAR_RADIUS_SITE)){
|
25 |
exit("Vous n'avez pas les droits d'écriture sur le fichier ".ALCASAR_RADIUS_SITE);
|
90 |
exit($l_no_writing_right_on_file.ALCASAR_RADIUS_SITE);
|
26 |
}
|
91 |
}
|
27 |
if (!is_readable(ALCASAR_RADIUS_MODULE_LDAP)){
|
92 |
if (!is_readable(ALCASAR_RADIUS_MODULE_LDAP)){
|
28 |
exit("Vous n'avez pas les droits d'écriture sur le fichier ".ALCASAR_RADIUS_MODULE_LDAP);
|
93 |
exit($l_no_writing_right_on_file.ALCASAR_RADIUS_MODULE_LDAP);
|
29 |
}
|
94 |
}
|
30 |
|
95 |
|
31 |
/********************************************************
|
96 |
/********************************************************
|
32 |
* VARIABLES DE FORMULAIRE *
|
97 |
* VARIABLES DE FORMULAIRE *
|
33 |
*********************************************************/
|
98 |
*********************************************************/
|
34 |
|
99 |
|
35 |
if (isset($_GET['erreur'])&&(!($_GET['erreur']==""))) $erreur = $_GET['erreur']; else $erreur = false;//valeur de $erreur non controlée car ne sert qu'un afficher un msg.
|
100 |
if (isset($_GET['erreur'])&&(!($_GET['erreur']==""))) $erreur = $_GET['erreur']; else $erreur = false;//valeur de $erreur non controlée car ne sert qu'un afficher un msg.
|
36 |
if (isset($_GET['update'])&&($_GET['update']=="ok")) $update = true; else $update = false;
|
101 |
if (isset($_GET['update'])&&($_GET['update']=="ok")) $update = true; else $update = false;
|
37 |
|
102 |
|
38 |
$message = "";
|
103 |
$message = "";
|
39 |
if ((bool)$erreur){
|
104 |
if ((bool)$erreur){
|
40 |
$message = "<div align=\"center\"><br>";
|
105 |
$message = "<div align=\"center\"><br>";
|
41 |
$message.="<strong><font color=\"red\">".$erreur."</font></strong><br>";
|
106 |
$message.="<strong><font color=\"red\">".$erreur."</font></strong><br>";
|
42 |
$message.="<br></div>";
|
107 |
$message.="<br></div>";
|
43 |
}else{
|
108 |
}else{
|
44 |
if ($update){
|
109 |
if ($update){
|
45 |
$message = "<div align=\"center\"><br>";
|
110 |
$message = "<div align=\"center\"><br>";
|
46 |
$message.="<strong><font color=\"green\">Mise à jour des paramètres ldap réalisé avec succès</font><br></strong>";
|
111 |
$message.="<strong><font color=\"green\">$l_ldap_update_sucess</font><br></strong>";
|
47 |
$message.="<br></div>";
|
112 |
$message.="<br></div>";
|
48 |
}
|
113 |
}
|
49 |
}
|
114 |
}
|
50 |
|
115 |
|
51 |
/****************************************************************
|
116 |
/****************************************************************
|
52 |
* VARIABLES RESULTATS *
|
117 |
* VARIABLES RESULTATS *
|
53 |
*****************************************************************/
|
118 |
*****************************************************************/
|
54 |
//Création des variables nécessaires
|
119 |
//Création des variables nécessaires
|
55 |
//variables ldap
|
120 |
//variables ldap
|
56 |
$ldap_on = "";
|
121 |
$ldap_on = "";
|
57 |
$ldap_server = ""; //IP ou nom DNS du seveur LDAP (ou AD)
|
122 |
$ldap_server = ""; //IP ou nom DNS du seveur LDAP (ou AD)
|
58 |
//par défaut : server = "ldap.your.domain"
|
123 |
//par défaut : server = "ldap.your.domain"
|
59 |
$ldap_identity = ""; //nom d'utilisateur qui intérroge le ldap (vide = anonyme)
|
124 |
$ldap_identity = ""; //nom d'utilisateur qui intérroge le ldap (vide = anonyme)
|
60 |
//par défaut : # identity = "cn=admin,o=My Org,c=UA"
|
125 |
//par défaut : # identity = "cn=admin,o=My Org,c=UA"
|
61 |
$ldap_password = ""; //mot de passe de l'utilisateur intérrogeant le ldap
|
126 |
$ldap_password = ""; //mot de passe de l'utilisateur intérrogeant le ldap
|
62 |
//par défaut : # password = mypass
|
127 |
//par défaut : # password = mypass
|
63 |
$ldap_basedn = ""; //DN de base ou l'on recherchera les utilisateurs
|
128 |
$ldap_basedn = ""; //DN de base ou l'on recherchera les utilisateurs
|
64 |
//par défaut : basedn = "o=My Org,c=UA"
|
129 |
//par défaut : basedn = "o=My Org,c=UA"
|
65 |
$ldap_filter = ""; //permet entre autre de déterminer l'attribut utilisé pour la recherche d'un utilisateur dans LDAP
|
130 |
$ldap_filter = ""; //permet entre autre de déterminer l'attribut utilisé pour la recherche d'un utilisateur dans LDAP
|
66 |
//attribut uid pour un ldap standard, samaccountname pour AD
|
131 |
//attribut uid pour un ldap standard, samaccountname pour AD
|
67 |
//par défaut : filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
|
132 |
//par défaut : filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
|
68 |
$ldap_base_filter = ""; //
|
133 |
$ldap_base_filter = ""; //
|
69 |
//par défaut : # base_filter = "(objectclass=radiusprofile)"
|
134 |
//par défaut : # base_filter = "(objectclass=radiusprofile)"
|
70 |
|
135 |
|
71 |
/********************************************************
|
136 |
/********************************************************
|
72 |
* Fichier ALCASAR_RADIUS_SITE *
|
137 |
* Fichier ALCASAR_RADIUS_SITE *
|
73 |
*********************************************************/
|
138 |
*********************************************************/
|
74 |
$site = new siteConfig();
|
139 |
$site = new siteConfig();
|
75 |
$site->load(ALCASAR_RADIUS_SITE);
|
140 |
$site->load(ALCASAR_RADIUS_SITE);
|
76 |
$ldap_on = $site->authorize->ldap;
|
141 |
$ldap_on = $site->authorize->ldap;
|
77 |
|
142 |
|
78 |
/********************************************************
|
143 |
/********************************************************
|
79 |
* Fichier ALCASAR_RADIUS_MODULE_LDAP *
|
144 |
* Fichier ALCASAR_RADIUS_MODULE_LDAP *
|
80 |
*********************************************************/
|
145 |
*********************************************************/
|
81 |
//Lecture du fichier /etc/raddb/modules/ldap
|
146 |
//Lecture du fichier /etc/raddb/modules/ldap
|
82 |
$ldap = new ldapConfig();
|
147 |
$ldap = new ldapConfig();
|
83 |
$ldap->load(ALCASAR_RADIUS_MODULE_LDAP);
|
148 |
$ldap->load(ALCASAR_RADIUS_MODULE_LDAP);
|
84 |
$ldap_server = $ldap->host; // others options only in alcasar 3.x ($ldap->server)
|
149 |
$ldap_server = $ldap->host; // others options only in alcasar 3.x ($ldap->server)
|
85 |
$ldap_identity = $ldap->identity;
|
150 |
$ldap_identity = $ldap->identity;
|
86 |
$ldap_password = $ldap->password;
|
151 |
$ldap_password = $ldap->password;
|
87 |
$ldap_basedn = $ldap->basedn;
|
152 |
$ldap_basedn = $ldap->basedn;
|
88 |
$ldap_filter = $ldap->uid;// others options only in alcasar 3.x ($ldap->filter)
|
153 |
$ldap_filter = $ldap->uid; // others options only in alcasar 3.x ($ldap->filter)
|
89 |
$ldap_base_filter = $ldap->base_filter;
|
154 |
$ldap_base_filter = $ldap->base_filter;
|
90 |
|
- |
|
91 |
|
- |
|
92 |
# Choice of language
|
- |
|
93 |
$Language = 'en';
|
- |
|
94 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
|
- |
|
95 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
- |
|
96 |
$Language = strtolower(substr(chop($Langue[0]),0,2)); }
|
- |
|
97 |
if($Language == 'fr'){
|
- |
|
98 |
$l_ldap_title = "Authentification externe : LDAP";
|
- |
|
99 |
$l_ldap_legend = "Authentification LDAP";
|
- |
|
100 |
$l_ldap_auth_enable_label = "Activer l'authentification LDAP:";
|
- |
|
101 |
$l_ldap_YES = "OUI";
|
- |
|
102 |
$l_ldap_NO = "NON";
|
- |
|
103 |
$l_ldap_server_label = "Nom du serveur LDAP:";
|
- |
|
104 |
$l_ldap_server_text = "Nom ou IP du serveur LDAP éventuel.";
|
- |
|
105 |
$l_ldap_base_dn_label = "DN de la base LDAP:";
|
- |
|
106 |
$l_ldap_base_dn_text = "DN est le 'Distinguished Name', il situe les informations utilisateurs, exemple: 'o=Mon entreprise, c=FR'.";
|
- |
|
107 |
$l_ldap_filter_label = "Identifiant LDAP:";
|
- |
|
108 |
$l_ldap_filter_text = "Clé utilisée pour la recherche d'un identifiant de connexion, exemple: 'uid', 'sn', etc. Pour un AD mettre 'sAMAccountName'.";
|
- |
|
109 |
$l_ldap_base_filter_label = "Filtre de l'utilisateur LDAP:";
|
- |
|
110 |
$l_ldap_base_filter_text = "Sur option, vous pouvez en plus limiter les objets recherchés avec des filtres additionnels. Par exemple 'objectClass=posixGroup' aurait comme conséquence l'utilisation de '(&(uid=username)(objectClass=posixGroup))'";
|
- |
|
111 |
$l_ldap_user_label = "Utilisateur LDAP:";
|
- |
|
112 |
$l_ldap_user_text = "Laissez vide pour utiliser un accès invité. Si renseigné, ALCASAR se connectera au serveur LDAP en tant qu'un utilisateur spécifié, exemple: 'uid=Utilisateur,ou=MonUnité,o=MaCompagnie,c=FR'. Requis pour les serveurs possédant un Active Directory.";
|
- |
|
113 |
$l_ldap_password_label = "Mot de passe LDAP:";
|
- |
|
114 |
$l_ldap_password_text = "Laissez vide pour un accès invité. Sinon, indiquez le mot de passe de connexion. Requis pour les serveurs possédant un Active Directory.";
|
- |
|
115 |
$l_ldap_submit = "Enregistrer";
|
- |
|
116 |
$l_ldap_reset = "Annuler";
|
- |
|
117 |
$l_ldap_test_network_failed = "Pas de connectivité réseau avec le serveur LDAP.";
|
- |
|
118 |
$l_ldap_test_connection_failed = "Impossible de se connecter au serveur LDAP.";
|
- |
|
119 |
$l_ldap_test_bind_ok = "Connexion LDAP réussie...";
|
- |
|
120 |
$l_ldap_test_bind_failed = "Echec d'authentification sur le serveur LDAP...Vérifiez votre configuration ldap...";
|
- |
|
121 |
} else {
|
- |
|
122 |
$l_ldap_title = "External authentication : LDAP";
|
- |
|
123 |
$l_ldap_legend = "LDAP authentication";
|
- |
|
124 |
$l_ldap_auth_enable_label = "Use LDAP authentication :";
|
- |
|
125 |
$l_ldap_YES = "YES";
|
- |
|
126 |
$l_ldap_NO = "NO";
|
- |
|
127 |
$l_ldap_server_label = "LDAP server name:";
|
- |
|
128 |
$l_ldap_server_text = "This is the hostname or IP address of the LDAP server.";
|
- |
|
129 |
$l_ldap_base_dn_label = "LDAP base dn:";
|
- |
|
130 |
$l_ldap_base_dn_text = "This is the 'Distinguished Name', locating the user information, e.g. 'o=My Company,c=US'.";
|
- |
|
131 |
$l_ldap_filter_label = "LDAP uid:";
|
- |
|
132 |
$l_ldap_filter_text = "This is the key under which to search for a given login identity, e.g. 'uid', 'sn', etc.. For AD use 'sAMAccountName'.";
|
- |
|
133 |
$l_ldap_base_filter_label = "LDAP user filter:";
|
- |
|
134 |
$l_ldap_base_filter_text = "Optionally you can further limit the searched objects with additional filters. For example 'objectClass=posixGroup' would result in the use of '(&(uid=username)(objectClass=posixGroup))'";
|
- |
|
135 |
$l_ldap_user_label = "LDAP user dn:";
|
- |
|
136 |
$l_ldap_user_text = "Leave blank to use anonymous binding. If filled, ALCASAR uses the specified distinguished name on login attempts to find the correct user, e.g. 'uid=Username,ou=MyUnit,o=MyCompany,c=US'. Required for Active Directory Servers.";
|
- |
|
137 |
$l_ldap_password_label = "LDAP password:";
|
- |
|
138 |
$l_ldap_password_text = "Leave blank to use anonymous binding. Else fill in the password for the above user. Required for Active Directory Servers.";
|
- |
|
139 |
$l_ldap_submit = "Save";
|
- |
|
140 |
$l_ldap_reset = "Reset";
|
- |
|
141 |
$l_ldap_test_network_failed = "LDAP server is not reachable.";
|
- |
|
142 |
$l_ldap_test_connection_failed = "LDAP connexion failed...";
|
- |
|
143 |
$l_ldap_test_bind_ok = "LDAP connexion success...";
|
- |
|
144 |
$l_ldap_test_bind_failed = "LDAP authentication failed...Check your ldap setup...";
|
- |
|
145 |
}
|
- |
|
146 |
|
155 |
|
147 |
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
|
156 |
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
|
148 |
// Test du serveur
|
157 |
// Test du serveur
|
149 |
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
|
158 |
if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
|
150 |
// no network connection
|
159 |
// no network connection
|
151 |
return -1;
|
160 |
return -1;
|
152 |
} else {
|
161 |
} else {
|
153 |
fclose($sock);
|
162 |
fclose($sock);
|
154 |
// Connexion au serveur LDAP
|
163 |
// Connexion au serveur LDAP
|
155 |
$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
|
164 |
$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
|
156 |
ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
|
165 |
ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
|
157 |
if ($ldapconn) {
|
166 |
if ($ldapconn) {
|
158 |
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
|
167 |
$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
|
159 |
if ($ldapbind) {
|
168 |
if ($ldapbind) {
|
160 |
// LDAP Bind success
|
169 |
// LDAP Bind success
|
161 |
ldap_unbind($ldapconn);
|
170 |
ldap_unbind($ldapconn);
|
162 |
return 1;
|
171 |
return 1;
|
163 |
} else {
|
172 |
} else {
|
164 |
// LDAP Bind failed
|
173 |
// LDAP Bind failed
|
165 |
return 0;
|
174 |
return 0;
|
166 |
}
|
175 |
}
|
167 |
} else {
|
176 |
} else {
|
168 |
// LDAP connection failed
|
177 |
// LDAP connection failed
|
169 |
return -2;
|
178 |
return -2;
|
170 |
}
|
179 |
}
|
171 |
}
|
180 |
}
|
172 |
}
|
181 |
}
|
173 |
|
182 |
|
174 |
/********************************
|
183 |
/********************************
|
175 |
* TO DO *
|
184 |
* TO DO *
|
176 |
*********************************/
|
185 |
*********************************/
|
177 |
//internationnalisation à mettre en haut du fichier pour internationnaliser les erreurs de script!
|
186 |
//internationnalisation à mettre en haut du fichier pour internationnaliser les erreurs de script!
|
178 |
?>
|
187 |
?>
|
179 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
188 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
180 |
<html><!-- written by steweb57 -->
|
189 |
<html><!-- written by steweb57 -->
|
181 |
<head>
|
190 |
<head>
|
182 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
191 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
183 |
<title><?php echo $l_ldap_title; ?></title>
|
192 |
<title><?php echo $l_ldap_title; ?></title>
|
184 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
193 |
<link rel="stylesheet" href="/css/style.css" type="text/css">
|
185 |
<link rel="stylesheet" href="/css/ldap.css" type="text/css">
|
194 |
<link rel="stylesheet" href="/css/ldap.css" type="text/css">
|
186 |
<script language="javascript">
|
195 |
<script language="javascript">
|
187 |
function testLdapActif(){
|
196 |
function testLdapActif(){
|
188 |
//List des ID des éléments à désactiver
|
197 |
//List des ID des éléments à désactiver
|
189 |
var listToDisables = new Array("ldap_server","ldap_dn","ldap_filter","ldap_base_filter","ldap_user","ldap_password");
|
198 |
var listToDisables = new Array("ldap_server","ldap_dn","ldap_filter","ldap_base_filter","ldap_user","ldap_password");
|
190 |
|
199 |
|
191 |
if (document.getElementById("auth_enable").value == "1"){
|
200 |
if (document.getElementById("auth_enable").value == "1"){
|
192 |
for (var i=0;i<listToDisables.length;i++){
|
201 |
for (var i=0;i<listToDisables.length;i++){
|
193 |
document.getElementById(listToDisables[i]).style.backgroundColor ="#ffffff";
|
202 |
document.getElementById(listToDisables[i]).style.backgroundColor ="#ffffff";
|
194 |
document.getElementById(listToDisables[i]).disabled = false;
|
203 |
document.getElementById(listToDisables[i]).disabled = false;
|
195 |
}
|
204 |
}
|
196 |
} else {
|
205 |
} else {
|
197 |
for (var i=0;i<listToDisables.length;i++){
|
206 |
for (var i=0;i<listToDisables.length;i++){
|
198 |
document.getElementById(listToDisables[i]).style.backgroundColor ="#c0c0c0";
|
207 |
document.getElementById(listToDisables[i]).style.backgroundColor ="#c0c0c0";
|
199 |
document.getElementById(listToDisables[i]).disabled = true;
|
208 |
document.getElementById(listToDisables[i]).disabled = true;
|
200 |
}
|
209 |
}
|
201 |
}
|
210 |
}
|
202 |
}
|
211 |
}
|
203 |
</script>
|
212 |
</script>
|
204 |
</head>
|
213 |
</head>
|
205 |
<body onLoad="testLdapActif();">
|
214 |
<body onLoad="testLdapActif();">
|
206 |
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
215 |
<table width="100%" border=0 cellspacing=0 cellpadding=0>
|
207 |
<tr><th><?php echo $l_ldap_legend; ?></th></tr>
|
216 |
<tr><th><?php echo $l_ldap_legend; ?></th></tr>
|
208 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
|
217 |
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
|
209 |
</table>
|
218 |
</table>
|
210 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
219 |
<table width="100%" border=1 cellspacing=0 cellpadding=1>
|
211 |
<tr><td valign="middle" align="left">
|
220 |
<tr><td valign="middle" align="left">
|
212 |
<form name="config_ldap" method="post" action="update_ldap.php">
|
221 |
<form name="config_ldap" method="post" action="update_ldap.php">
|
213 |
<fieldset>
|
222 |
<fieldset>
|
214 |
<legend>
|
223 |
<legend>
|
215 |
<?php
|
224 |
<?php
|
216 |
echo $message;
|
225 |
echo $message;
|
217 |
$pos = strpos($ldap_server, "//");
|
226 |
$pos = strpos($ldap_server, "//");
|
218 |
if ($pos!==false){
|
227 |
if ($pos!==false){
|
219 |
$new_ldap_server = explode("//",$ldap_server); //pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
|
228 |
$new_ldap_server = explode("//",$ldap_server); //pour discriminer le host et le protocole dans la notation "ldap://192.168.182.10" ou "ldaps://monldap.monentreperise.com"
|
220 |
} else {
|
229 |
} else {
|
221 |
$new_ldap_server = $ldap_server;
|
230 |
$new_ldap_server = $ldap_server;
|
222 |
}
|
231 |
}
|
223 |
if (($ldap_on == "ldap") && (function_exists('ldap_connect'))){
|
232 |
if (($ldap_on == "ldap") && (function_exists('ldap_connect'))){
|
224 |
echo "<div align='center'><br>";
|
233 |
echo "<div align='center'><br>";
|
225 |
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){
|
234 |
switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){
|
226 |
case -2:
|
235 |
case -2:
|
227 |
echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
|
236 |
echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
|
228 |
break;
|
237 |
break;
|
229 |
case -1:
|
238 |
case -1:
|
230 |
echo "<font color='red'>".$l_ldap_test_network_failed."</font>";
|
239 |
echo "<font color='red'>".$l_ldap_test_network_failed."</font>";
|
231 |
break;
|
240 |
break;
|
232 |
case 0:
|
241 |
case 0:
|
233 |
echo "<font color='red'>".$l_ldap_test_bind_failed."</font>";
|
242 |
echo "<font color='red'>".$l_ldap_test_bind_failed."</font>";
|
234 |
break;
|
243 |
break;
|
235 |
case 1:
|
244 |
case 1:
|
236 |
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
|
245 |
echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
|
237 |
break;
|
246 |
break;
|
238 |
default:
|
247 |
default:
|
239 |
echo "LDAP error";
|
248 |
echo "LDAP error";
|
240 |
}
|
249 |
}
|
241 |
echo "<br><br></div>";
|
250 |
echo "<br><br></div>";
|
242 |
}
|
251 |
}
|
243 |
?>
|
252 |
?>
|
244 |
</legend>
|
253 |
</legend>
|
245 |
<dl>
|
254 |
<dl>
|
246 |
<dt>
|
255 |
<dt>
|
247 |
<label for="auth_enable"><?php echo $l_ldap_auth_enable_label; ?></label>
|
256 |
<label for="auth_enable"><?php echo $l_ldap_auth_enable_label; ?></label>
|
248 |
</dt>
|
257 |
</dt>
|
249 |
<dd>
|
258 |
<dd>
|
250 |
<select id="auth_enable" name="auth_enable" onchange="testLdapActif();">
|
259 |
<select id="auth_enable" name="auth_enable" onchange="testLdapActif();">
|
251 |
<?php if ($ldap_on == "ldap") {
|
260 |
<?php if ($ldap_on == "ldap") {
|
252 |
echo "<option value=\"1\" selected=\"selected\">$l_ldap_YES</option>";
|
261 |
echo "<option value=\"1\" selected=\"selected\">$l_ldap_YES</option>";
|
253 |
echo "<option value=\"0\">$l_ldap_NO</option>";
|
262 |
echo "<option value=\"0\">$l_ldap_NO</option>";
|
254 |
}else{
|
263 |
}else{
|
255 |
echo "<option value=\"1\">$l_ldap_YES</option>";
|
264 |
echo "<option value=\"1\">$l_ldap_YES</option>";
|
256 |
echo "<option value=\"0\" selected=\"selected\">$l_ldap_NO</option>";
|
265 |
echo "<option value=\"0\" selected=\"selected\">$l_ldap_NO</option>";
|
257 |
}?>
|
266 |
}?>
|
258 |
</select>
|
267 |
</select>
|
259 |
</dd>
|
268 |
</dd>
|
260 |
</dl>
|
269 |
</dl>
|
261 |
<dl>
|
270 |
<dl>
|
262 |
<dt>
|
271 |
<dt>
|
263 |
<label for="ldap_server"><?php echo $l_ldap_server_label; ?></label>
|
272 |
<label for="ldap_server"><?php echo $l_ldap_server_label; ?></label>
|
264 |
<br>
|
273 |
<br>
|
265 |
<?php echo $l_ldap_server_text; ?></dt>
|
274 |
<?php echo $l_ldap_server_text; ?></dt>
|
266 |
<dd>
|
275 |
<dd>
|
267 |
<input id="ldap_server" size="40" name="ldap_server" value="<?php echo htmlspecialchars($ldap_server); ?>">
|
276 |
<input id="ldap_server" size="40" name="ldap_server" value="<?php echo htmlspecialchars($ldap_server); ?>">
|
268 |
</dd>
|
277 |
</dd>
|
269 |
</dl>
|
278 |
</dl>
|
270 |
<dl>
|
279 |
<dl>
|
271 |
<dt>
|
280 |
<dt>
|
272 |
<label for="ldap_dn"><?php echo $l_ldap_base_dn_label; ?></label>
|
281 |
<label for="ldap_dn"><?php echo $l_ldap_base_dn_label; ?></label>
|
273 |
<br>
|
282 |
<br>
|
274 |
<?php echo $l_ldap_base_dn_text; ?></dt>
|
283 |
<?php echo $l_ldap_base_dn_text; ?></dt>
|
275 |
<dd>
|
284 |
<dd>
|
276 |
<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?php echo htmlspecialchars($ldap_basedn); ?>">
|
285 |
<input id="ldap_dn" size="40" name="ldap_base_dn" value="<?php echo htmlspecialchars($ldap_basedn); ?>">
|
277 |
</dd>
|
286 |
</dd>
|
278 |
</dl>
|
287 |
</dl>
|
279 |
<dl>
|
288 |
<dl>
|
280 |
<dt>
|
289 |
<dt>
|
281 |
<label for="ldap_filter"><?php echo $l_ldap_filter_label; ?></label>
|
290 |
<label for="ldap_filter"><?php echo $l_ldap_filter_label; ?></label>
|
282 |
<br>
|
291 |
<br>
|
283 |
<?php echo $l_ldap_filter_text; ?></dt>
|
292 |
<?php echo $l_ldap_filter_text; ?></dt>
|
284 |
<dd>
|
293 |
<dd>
|
285 |
<input id="ldap_filter" size="40" name="ldap_filter" value="<?php echo htmlspecialchars($ldap_filter); ?>">
|
294 |
<input id="ldap_filter" size="40" name="ldap_filter" value="<?php echo htmlspecialchars($ldap_filter); ?>">
|
286 |
</dd>
|
295 |
</dd>
|
287 |
</dl>
|
296 |
</dl>
|
288 |
<dl>
|
297 |
<dl>
|
289 |
<dt>
|
298 |
<dt>
|
290 |
<label for="ldap_base_filter"><?php echo $l_ldap_base_filter_label; ?></label>
|
299 |
<label for="ldap_base_filter"><?php echo $l_ldap_base_filter_label; ?></label>
|
291 |
<br>
|
300 |
<br>
|
292 |
<?php echo $l_ldap_base_filter_text; ?></dt>
|
301 |
<?php echo $l_ldap_base_filter_text; ?></dt>
|
293 |
<dd>
|
302 |
<dd>
|
294 |
<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?php echo htmlspecialchars($ldap_base_filter); ?>">
|
303 |
<input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?php echo htmlspecialchars($ldap_base_filter); ?>">
|
295 |
</dd>
|
304 |
</dd>
|
296 |
</dl>
|
305 |
</dl>
|
297 |
<dl>
|
306 |
<dl>
|
298 |
<dt>
|
307 |
<dt>
|
299 |
<label for="ldap_user"><?php echo $l_ldap_user_label; ?></label>
|
308 |
<label for="ldap_user"><?php echo $l_ldap_user_label; ?></label>
|
300 |
<br>
|
309 |
<br>
|
301 |
<?php echo $l_ldap_user_text; ?></dt>
|
310 |
<?php echo $l_ldap_user_text; ?></dt>
|
302 |
<dd>
|
311 |
<dd>
|
303 |
<input id="ldap_user" size="40" name="ldap_user" value="<?php echo htmlspecialchars($ldap_identity); ?>">
|
312 |
<input id="ldap_user" size="40" name="ldap_user" value="<?php echo htmlspecialchars($ldap_identity); ?>">
|
304 |
</dd>
|
313 |
</dd>
|
305 |
</dl>
|
314 |
</dl>
|
306 |
<dl>
|
315 |
<dl>
|
307 |
<dt>
|
316 |
<dt>
|
308 |
<label for="ldap_password"><?php echo $l_ldap_password_label; ?></label>
|
317 |
<label for="ldap_password"><?php echo $l_ldap_password_label; ?></label>
|
309 |
<br>
|
318 |
<br>
|
310 |
<?php echo $l_ldap_password_text; ?></dt>
|
319 |
<?php echo $l_ldap_password_text; ?></dt>
|
311 |
<dd>
|
320 |
<dd>
|
312 |
<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?php echo htmlspecialchars($ldap_password);?>">
|
321 |
<input id="ldap_password" type="password" size="40" name="ldap_password" value="<?php echo htmlspecialchars($ldap_password);?>">
|
313 |
</dd>
|
322 |
</dd>
|
314 |
</dl>
|
323 |
</dl>
|
315 |
<p>
|
324 |
<p>
|
316 |
<input id="submit" type="submit" value="<?php echo $l_ldap_submit; ?>" name="submit">
|
325 |
<input id="submit" type="submit" value="<?php echo $l_ldap_submit; ?>" name="submit">
|
317 |
|
326 |
|
318 |
<input id="reset" type="reset" value="<?php echo $l_ldap_reset; ?>" name="reset">
|
327 |
<input id="reset" type="reset" value="<?php echo $l_ldap_reset; ?>" name="reset">
|
319 |
</p>
|
328 |
</p>
|
320 |
|
329 |
|
321 |
</fieldset>
|
330 |
</fieldset>
|
322 |
</form>
|
331 |
</form>
|
323 |
<br>
|
332 |
<br>
|
324 |
</td></tr>
|
333 |
</td></tr>
|
325 |
</table>
|
334 |
</table>
|
326 |
</body>
|
335 |
</body>
|
327 |
</html>
|
336 |
</html>
|
328 |
|
337 |
|