Subversion Repositories ALCASAR

Rev

Rev 1160 | Rev 1672 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log

Rev 1160 Rev 1395
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
/****************************************************************
13
/****************************************************************
14
*						Choice of language						*
14
*						Choice of language						*
15
*****************************************************************/
15
*****************************************************************/
16
 
16
 
17
$Language = 'en';
17
$Language = 'en';
18
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
18
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])){
19
	$Langue	= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
19
	$Langue	= explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
20
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
20
	$Language	= strtolower(substr(chop($Langue[0]),0,2)); }
21
if($Language == 'fr'){
21
if($Language == 'fr'){
22
	$l_file						= "Fichier ";
22
	$l_file						= "Fichier ";
23
	$l_not_found				= " non présent";
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 ";
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";
25
	$l_ldap_update_sucess		= "Mise à jour des paramètres LDAP réalisée avec succès";
26
	$l_ldap_title				= "Authentification externe : LDAP";
26
	$l_ldap_title				= "Authentification externe : LDAP";
27
	$l_ldap_legend				= "Authentification LDAP";
27
	$l_ldap_legend				= "Authentification LDAP";
28
	$l_ldap_auth_enable_label	= "Activer l'authentification LDAP:";
28
	$l_ldap_auth_enable_label	= "Activer l'authentification LDAP:";
29
	$l_ldap_YES					= "OUI";
29
	$l_ldap_YES					= "OUI";
30
	$l_ldap_NO					= "NON";
30
	$l_ldap_NO					= "NON";
31
	$l_ldap_server_label		= "Nom du serveur LDAP:";
31
	$l_ldap_server_label		= "Nom du serveur LDAP:";
32
	$l_ldap_server_text			= "Nom ou IP du serveur LDAP éventuel.";
32
	$l_ldap_server_text			= "Nom ou IP du serveur LDAP éventuel.";
33
	$l_ldap_base_dn_label		= "DN de la base LDAP:";
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'.";
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:";
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'.";
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:";
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 '(&amp;(uid=username)(objectClass=posixGroup))'";
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 '(&amp;(uid=username)(objectClass=posixGroup))'";
39
	$l_ldap_user_label			= "Utilisateur LDAP:";
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.";
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:";
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.";
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";
43
	$l_ldap_submit				= "Enregistrer";
44
	$l_ldap_reset				= "Annuler";
44
	$l_ldap_reset				= "Annuler";
45
	$l_ldap_test_network_failed	= "Pas de connectivité réseau avec le serveur LDAP.";
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.";
46
	$l_ldap_test_connection_failed	= "Impossible de se connecter au serveur LDAP.";
47
	$l_ldap_test_bind_ok		= "Connexion LDAP réussie...";
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...";
48
	$l_ldap_test_bind_failed	= "Echec d'authentification sur le serveur LDAP...Vérifiez votre configuration ldap...";
-
 
49
	$l_ldap_test_dn_ok		= "DN semble bon";
-
 
50
	$l_ldap_test_dn_failed		= "DN semble mauvais";
49
} else {
51
} else {
50
	$l_file						= "File ";
52
	$l_file						= "File ";
51
	$l_not_found				= " not found";
53
	$l_not_found				= " not found";
52
	$l_no_writing_right_on_file	= "You have no writting permission on the file ";
54
	$l_no_writing_right_on_file	= "You have no writting permission on the file ";
53
	$l_ldap_update_sucess		= "Successfull LDAP settings update";
55
	$l_ldap_update_sucess		= "Successfull LDAP settings update";
54
	$l_ldap_title				= "External authentication : LDAP";
56
	$l_ldap_title				= "External authentication : LDAP";
55
	$l_ldap_legend				= "LDAP authentication";
57
	$l_ldap_legend				= "LDAP authentication";
56
	$l_ldap_auth_enable_label	= "Use LDAP authentication :";
58
	$l_ldap_auth_enable_label	= "Use LDAP authentication :";
57
	$l_ldap_YES					= "YES";
59
	$l_ldap_YES					= "YES";
58
	$l_ldap_NO					= "NO";
60
	$l_ldap_NO					= "NO";
59
	$l_ldap_server_label		= "LDAP server name:";
61
	$l_ldap_server_label		= "LDAP server name:";
60
	$l_ldap_server_text			= "This is the hostname or IP address of the LDAP server.";
62
	$l_ldap_server_text			= "This is the hostname or IP address of the LDAP server.";
61
	$l_ldap_base_dn_label		= "LDAP base dn:";
63
	$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'.";
64
	$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:";
65
	$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'.";
66
	$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:";
67
	$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 '(&amp;(uid=username)(objectClass=posixGroup))'";
68
	$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 '(&amp;(uid=username)(objectClass=posixGroup))'";
67
	$l_ldap_user_label			= "LDAP user dn:";
69
	$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.";
70
	$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:";
71
	$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.";
72
	$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";
73
	$l_ldap_submit				= "Save";
72
	$l_ldap_reset				= "Reset";
74
	$l_ldap_reset				= "Reset";
73
	$l_ldap_test_network_failed	= "LDAP server is not reachable.";
75
	$l_ldap_test_network_failed	= "LDAP server is not reachable.";
74
	$l_ldap_test_connection_failed	= "LDAP connexion failed...";
76
	$l_ldap_test_connection_failed	= "LDAP connexion failed...";
75
	$l_ldap_test_bind_ok		= "LDAP connexion success...";
77
	$l_ldap_test_bind_ok		= "LDAP connexion success...";
76
	$l_ldap_test_bind_failed	= "LDAP authentication failed...Check your ldap setup...";
78
	$l_ldap_test_bind_failed	= "LDAP authentication failed...Check your ldap setup...";
-
 
79
	$l_ldap_test_dn_ok              = "DN seems to be right";
-
 
80
	$l_ldap_test_dn_failed          = "DN seems to be wrong";
77
}
81
}
78
/********************************************************
82
/********************************************************
79
*		TEST DES FICHIERS DE CONFIGURATION	*
83
*		TEST DES FICHIERS DE CONFIGURATION	*
80
*********************************************************/
84
*********************************************************/
81
 
85
 
82
//Test de présence et des droits en lecture des fichiers de configuration.
86
//Test de présence et des droits en lecture des fichiers de configuration.
83
if (!file_exists(ALCASAR_RADIUS_SITE)){
87
if (!file_exists(ALCASAR_RADIUS_SITE)){
84
	exit($l_file.ALCASAR_RADIUS_SITE.$l_not_found);
88
	exit($l_file.ALCASAR_RADIUS_SITE.$l_not_found);
85
}
89
}
86
if (!file_exists(ALCASAR_RADIUS_MODULE_LDAP)){
90
if (!file_exists(ALCASAR_RADIUS_MODULE_LDAP)){
87
	exit($l_file.ALCASAR_RADIUS_MODULE_LDAP.$l_not_found);
91
	exit($l_file.ALCASAR_RADIUS_MODULE_LDAP.$l_not_found);
88
}
92
}
89
if (!is_readable(ALCASAR_RADIUS_SITE)){
93
if (!is_readable(ALCASAR_RADIUS_SITE)){
90
	exit($l_no_writing_right_on_file.ALCASAR_RADIUS_SITE);
94
	exit($l_no_writing_right_on_file.ALCASAR_RADIUS_SITE);
91
}
95
}
92
if (!is_readable(ALCASAR_RADIUS_MODULE_LDAP)){
96
if (!is_readable(ALCASAR_RADIUS_MODULE_LDAP)){
93
	exit($l_no_writing_right_on_file.ALCASAR_RADIUS_MODULE_LDAP);
97
	exit($l_no_writing_right_on_file.ALCASAR_RADIUS_MODULE_LDAP);
94
}
98
}
95
 
99
 
96
/********************************************************
100
/********************************************************
97
*		VARIABLES DE FORMULAIRE			*
101
*		VARIABLES DE FORMULAIRE			*
98
*********************************************************/
102
*********************************************************/
99
 
103
 
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.
104
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.
101
if (isset($_GET['update'])&&($_GET['update']=="ok")) $update = true; else $update = false;
105
if (isset($_GET['update'])&&($_GET['update']=="ok")) $update = true; else $update = false;
102
 
106
 
103
$message = "";
107
$message = "";
104
if ((bool)$erreur){ 
108
if ((bool)$erreur){ 
105
	$message = "<div align=\"center\"><br>";
109
	$message = "<div align=\"center\"><br>";
106
	$message.="<strong><font color=\"red\">".$erreur."</font></strong><br>";
110
	$message.="<strong><font color=\"red\">".$erreur."</font></strong><br>";
107
	$message.="<br></div>";
111
	$message.="<br></div>";
108
}else{
112
}else{
109
	if ($update){
113
	if ($update){
110
		$message = "<div align=\"center\"><br>";
114
		$message = "<div align=\"center\"><br>";
111
		$message.="<strong><font color=\"green\">$l_ldap_update_sucess</font><br></strong>";
115
		$message.="<strong><font color=\"green\">$l_ldap_update_sucess</font><br></strong>";
112
		$message.="<br></div>";
116
		$message.="<br></div>";
113
	}
117
	}
114
}
118
}
115
 
119
 
116
/****************************************************************
120
/****************************************************************
117
*			VARIABLES RESULTATS			*
121
*			VARIABLES RESULTATS			*
118
*****************************************************************/
122
*****************************************************************/
119
//Création des variables nécessaires
123
//Création des variables nécessaires
120
//variables ldap
124
//variables ldap
121
$ldap_on		= "";
125
$ldap_on		= "";
122
$ldap_server	= ""; 	//IP ou nom DNS du seveur LDAP (ou AD)
126
$ldap_server	= ""; 	//IP ou nom DNS du seveur LDAP (ou AD)
123
						//par défaut : server = "ldap.your.domain"
127
						//par défaut : server = "ldap.your.domain"
124
$ldap_identity	= "";	//nom d'utilisateur qui intérroge le ldap (vide = anonyme)
128
$ldap_identity	= "";	//nom d'utilisateur qui intérroge le ldap (vide = anonyme)
125
						//par défaut : # identity = "cn=admin,o=My Org,c=UA"
129
						//par défaut : # identity = "cn=admin,o=My Org,c=UA"
126
$ldap_password	= "";	//mot de passe de l'utilisateur intérrogeant le ldap
130
$ldap_password	= "";	//mot de passe de l'utilisateur intérrogeant le ldap
127
						//par défaut : # password = mypass
131
						//par défaut : # password = mypass
128
$ldap_basedn	= "";	//DN de base ou l'on recherchera les utilisateurs 
132
$ldap_basedn	= "";	//DN de base ou l'on recherchera les utilisateurs 
129
						//par défaut : basedn = "o=My Org,c=UA"
133
						//par défaut : basedn = "o=My Org,c=UA"
130
$ldap_filter	= "";	//permet entre autre de déterminer l'attribut utilisé pour la recherche d'un utilisateur dans LDAP
134
$ldap_filter	= "";	//permet entre autre de déterminer l'attribut utilisé pour la recherche d'un utilisateur dans LDAP
131
						//attribut uid pour un ldap standard, samaccountname pour AD
135
						//attribut uid pour un ldap standard, samaccountname pour AD
132
						//par défaut : filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
136
						//par défaut : filter = "(uid=%{Stripped-User-Name:-%{User-Name}})"
133
$ldap_base_filter = "";	//
137
$ldap_base_filter = "";	//
134
						//par défaut : # base_filter = "(objectclass=radiusprofile)"
138
						//par défaut : # base_filter = "(objectclass=radiusprofile)"
135
 
139
 
136
/********************************************************
140
/********************************************************
137
*		Fichier ALCASAR_RADIUS_SITE						*
141
*		Fichier ALCASAR_RADIUS_SITE						*
138
*********************************************************/
142
*********************************************************/
139
$site = new siteConfig();
143
$site = new siteConfig();
140
$site->load(ALCASAR_RADIUS_SITE);
144
$site->load(ALCASAR_RADIUS_SITE);
141
$ldap_on = $site->authorize->ldap;
145
$ldap_on = $site->authorize->ldap;
142
 
146
 
143
/********************************************************
147
/********************************************************
144
*		Fichier ALCASAR_RADIUS_MODULE_LDAP				*
148
*		Fichier ALCASAR_RADIUS_MODULE_LDAP				*
145
*********************************************************/
149
*********************************************************/
146
//Lecture du fichier /etc/raddb/modules/ldap
150
//Lecture du fichier /etc/raddb/modules/ldap
147
$ldap = new ldapConfig();
151
$ldap = new ldapConfig();
148
$ldap->load(ALCASAR_RADIUS_MODULE_LDAP);
152
$ldap->load(ALCASAR_RADIUS_MODULE_LDAP);
149
$ldap_server		= $ldap->host;		// others options only in alcasar 3.x ($ldap->server)
153
$ldap_server		= $ldap->host;		// others options only in alcasar 3.x ($ldap->server)
150
$ldap_identity		= $ldap->identity;
154
$ldap_identity		= $ldap->identity;
151
$ldap_password		= $ldap->password;
155
$ldap_password		= $ldap->password;
152
$ldap_basedn		= $ldap->basedn;
156
$ldap_basedn		= $ldap->basedn;
153
$ldap_filter		= $ldap->uid;		// others options only in alcasar 3.x ($ldap->filter)
157
$ldap_filter		= $ldap->uid;		// others options only in alcasar 3.x ($ldap->filter)
154
$ldap_base_filter	= $ldap->base_filter;
158
$ldap_base_filter	= $ldap->base_filter;
155
 
159
 
156
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_port = "389"){
160
function ldap_test($f_ldap_server, $f_ldap_identity, $f_ldap_password, $f_ldap_basedn, $f_ldap_filter, $f_ldap_port = "389"){
157
	// Test du serveur
161
	// Test du serveur
158
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
162
	if (!$sock = @fsockopen($f_ldap_server, $f_ldap_port, $num, $error, 2)) {
159
		// no network connection
163
		// no network connection
160
		return -1;
164
		return -1;
161
	} else {
165
	} else {
162
		fclose($sock);
166
		fclose($sock);
163
		// Connexion au serveur LDAP
167
		// Connexion au serveur LDAP
164
		$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
168
		$ldapconn = ldap_connect($f_ldap_server, $f_ldap_port);
165
		ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
169
		ldap_set_option($ldapconn, LDAP_OPT_TIMELIMIT, 2);
166
		if ($ldapconn) {
170
		if ($ldapconn) {
167
			$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
171
			$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
168
			if ($ldapbind) {
172
			if ($ldapbind) {
169
				// LDAP Bind success
173
				// LDAP Bind success
-
 
174
				//try search
-
 
175
				$query = $f_ldap_filter."=*";
-
 
176
				if($search = ldap_search($ldapconn, $f_ldap_basedn, $query)){
-
 
177
				 	ldap_unbind($ldapconn);      
-
 
178
					return 2;
-
 
179
				} else {
170
				ldap_unbind($ldapconn);
180
					ldap_unbind($ldapconn);
171
				return 1;
181
					return 1;
-
 
182
				}
-
 
183
			} else {
-
 
184
				// Test LDAP Version 3
-
 
185
				ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3);
-
 
186
				$ldapbind = ldap_bind($ldapconn, $f_ldap_identity, $f_ldap_password);
-
 
187
				if ($ldapbind) {
-
 
188
					// LDAP Bind success
-
 
189
					//try search
-
 
190
					$query = $f_ldap_filter."=*";
-
 
191
					if($search = ldap_search($ldapconn, $f_ldap_basedn, $query)){
-
 
192
						ldap_unbind($ldapconn);
-
 
193
						return 2;
-
 
194
					} else {
-
 
195
				ldap_unbind($ldapconn);
-
 
196
				return 1;
-
 
197
					}
172
			} else {
198
				} else {
173
				// LDAP Bind failed
199
					// LDAP Bind failed
174
				return 0;
200
					return 0;
175
			}
201
				}
-
 
202
			}
176
		} else {
203
		} else {
177
			// LDAP connection failed
204
			// LDAP connection failed
178
			return -2;
205
			return -2;
179
		}
206
		}
-
 
207
 
180
	}
208
	}
181
}
209
}
182
 
210
 
183
/********************************
211
/********************************
184
*		TO DO		*
212
*		TO DO		*
185
*********************************/
213
*********************************/
186
//internationnalisation à mettre en haut du fichier pour internationnaliser les erreurs de script!
214
//internationnalisation à mettre en haut du fichier pour internationnaliser les erreurs de script!
187
?>
215
?>
188
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
216
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
189
<html><!-- written by steweb57 -->
217
<html><!-- written by steweb57 -->
190
<head>
218
<head>
191
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
219
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
192
<title><?php echo $l_ldap_title; ?></title>
220
<title><?php echo $l_ldap_title; ?></title>
193
<link rel="stylesheet" href="/css/style.css" type="text/css">
221
<link rel="stylesheet" href="/css/style.css" type="text/css">
194
<link rel="stylesheet" href="/css/ldap.css" type="text/css">
222
<link rel="stylesheet" href="/css/ldap.css" type="text/css">
195
<script language="javascript">
223
<script language="javascript">
196
function testLdapActif(){
224
function testLdapActif(){
197
	//List des ID des éléments à désactiver
225
	//List des ID des éléments à désactiver
198
	var listToDisables = new Array("ldap_server","ldap_dn","ldap_filter","ldap_base_filter","ldap_user","ldap_password");
226
	var listToDisables = new Array("ldap_server","ldap_dn","ldap_filter","ldap_base_filter","ldap_user","ldap_password");
199
 
227
 
200
	if (document.getElementById("auth_enable").value == "1"){
228
	if (document.getElementById("auth_enable").value == "1"){
201
		for (var i=0;i<listToDisables.length;i++){
229
		for (var i=0;i<listToDisables.length;i++){
202
			document.getElementById(listToDisables[i]).style.backgroundColor ="#ffffff";
230
			document.getElementById(listToDisables[i]).style.backgroundColor ="#ffffff";
203
			document.getElementById(listToDisables[i]).disabled = false;
231
			document.getElementById(listToDisables[i]).disabled = false;
204
		}
232
		}
205
	} else {
233
	} else {
206
		for (var i=0;i<listToDisables.length;i++){
234
		for (var i=0;i<listToDisables.length;i++){
207
			document.getElementById(listToDisables[i]).style.backgroundColor ="#c0c0c0";
235
			document.getElementById(listToDisables[i]).style.backgroundColor ="#c0c0c0";
208
			document.getElementById(listToDisables[i]).disabled = true;
236
			document.getElementById(listToDisables[i]).disabled = true;
209
		}
237
		}
210
	}
238
	}
211
}
239
}
212
</script>
240
</script>
213
</head>
241
</head>
214
<body onLoad="testLdapActif();">
242
<body onLoad="testLdapActif();">
215
<table width="100%" border=0 cellspacing=0 cellpadding=0>
243
<table width="100%" border=0 cellspacing=0 cellpadding=0>
216
<tr><th><?php echo $l_ldap_legend; ?></th></tr>
244
<tr><th><?php echo $l_ldap_legend; ?></th></tr>
217
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
245
<tr bgcolor="#FFCC66"><td><img src="/images/pix.gif" width=1 height=2></td></tr>
218
</table>
246
</table>
219
<table width="100%" border=1 cellspacing=0 cellpadding=1>
247
<table width="100%" border=1 cellspacing=0 cellpadding=1>
220
<tr><td valign="middle" align="left">
248
<tr><td valign="middle" align="left">
221
<form name="config_ldap" method="post" action="update_ldap.php">
249
<form name="config_ldap" method="post" action="update_ldap.php">
222
<fieldset>
250
<fieldset>
223
<legend>
251
<legend>
224
<?php
252
<?php
225
echo $message;
253
echo $message;
226
$pos = strpos($ldap_server, "//");
254
$pos = strpos($ldap_server, "//");
227
if ($pos!==false){
255
if ($pos!==false){
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"
256
	$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"
229
} else {
257
} else {
230
	$new_ldap_server = $ldap_server;
258
	$new_ldap_server = $ldap_server;
231
}
259
}
232
if (($ldap_on == "ldap") && (function_exists('ldap_connect'))){
260
if (($ldap_on == "ldap") && (function_exists('ldap_connect'))){
233
	echo "<div align='center'><br>";	
261
	echo "<div align='center'><br>";	
-
 
262
 
234
	switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password)){
263
	switch(ldap_test($new_ldap_server, $ldap_identity, $ldap_password, $ldap_basedn, $ldap_filter)){
235
		case -2:
264
		case -2:
236
			echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
265
			echo "<font color='red'>".$l_ldap_test_connection_failed."</font>";
237
			break;
266
			break;
238
		case -1:
267
		case -1:
239
			echo "<font color='red'>".$l_ldap_test_network_failed."</font>";
268
			echo "<font color='red'>".$l_ldap_test_network_failed."</font>";
240
			break;
269
			break;
241
		case 0:
270
		case 0:
242
			echo "<font color='red'>".$l_ldap_test_bind_failed."</font>";
271
			echo "<font color='red'>".$l_ldap_test_bind_failed."</font>";
243
			break;
272
			break;
244
		case 1:
273
		case 1:
245
			echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
274
			echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
-
 
275
			echo "<br>";
-
 
276
			echo "<font color='red'>".$l_ldap_test_dn_failed."</font>";
-
 
277
			break;
-
 
278
		case 2:
-
 
279
			echo "<font color='green'>".$l_ldap_test_bind_ok."</font>";
-
 
280
			echo "<br>";
-
 
281
			echo "<font color='green'>".$l_ldap_test_dn_ok."</font>";
246
		break;
282
		break;
247
		default:
283
		default:
248
			echo "LDAP error";
284
			echo "LDAP error";
249
	}
285
	}
250
	echo "<br><br></div>"; 
286
	echo "<br><br></div>"; 
251
}
287
}
252
?>
288
?>
253
</legend>
289
</legend>
254
<dl>
290
<dl>
255
  <dt>
291
  <dt>
256
    <label for="auth_enable"><?php echo $l_ldap_auth_enable_label; ?></label>
292
    <label for="auth_enable"><?php echo $l_ldap_auth_enable_label; ?></label>
257
  </dt>
293
  </dt>
258
  <dd>
294
  <dd>
259
    <select id="auth_enable" name="auth_enable" onchange="testLdapActif();">
295
    <select id="auth_enable" name="auth_enable" onchange="testLdapActif();">
260
	<?php if ($ldap_on == "ldap") { 
296
	<?php if ($ldap_on == "ldap") { 
261
      echo "<option value=\"1\" selected=\"selected\">$l_ldap_YES</option>";
297
      echo "<option value=\"1\" selected=\"selected\">$l_ldap_YES</option>";
262
      echo "<option value=\"0\">$l_ldap_NO</option>";	
298
      echo "<option value=\"0\">$l_ldap_NO</option>";	
263
	}else{
299
	}else{
264
      echo "<option value=\"1\">$l_ldap_YES</option>";
300
      echo "<option value=\"1\">$l_ldap_YES</option>";
265
      echo "<option value=\"0\" selected=\"selected\">$l_ldap_NO</option>";
301
      echo "<option value=\"0\" selected=\"selected\">$l_ldap_NO</option>";
266
	}?>
302
	}?>
267
    </select>
303
    </select>
268
  </dd>
304
  </dd>
269
</dl>
305
</dl>
270
<dl>
306
<dl>
271
  <dt>
307
  <dt>
272
    <label for="ldap_server"><?php echo $l_ldap_server_label; ?></label>
308
    <label for="ldap_server"><?php echo $l_ldap_server_label; ?></label>
273
    <br>
309
    <br>
274
    <?php echo $l_ldap_server_text; ?></dt>
310
    <?php echo $l_ldap_server_text; ?></dt>
275
  <dd>
311
  <dd>
276
    <input id="ldap_server" size="40" name="ldap_server" value="<?php echo htmlspecialchars($ldap_server); ?>">
312
    <input id="ldap_server" size="40" name="ldap_server" value="<?php echo htmlspecialchars($ldap_server); ?>">
277
  </dd>
313
  </dd>
278
</dl>
314
</dl>
279
<dl>
315
<dl>
280
  <dt>
316
  <dt>
281
    <label for="ldap_dn"><?php echo $l_ldap_base_dn_label; ?></label>
317
    <label for="ldap_dn"><?php echo $l_ldap_base_dn_label; ?></label>
282
    <br>
318
    <br>
283
    <?php echo $l_ldap_base_dn_text; ?></dt>
319
    <?php echo $l_ldap_base_dn_text; ?></dt>
284
  <dd>
320
  <dd>
285
    <input id="ldap_dn" size="40" name="ldap_base_dn" value="<?php echo htmlspecialchars($ldap_basedn); ?>">
321
    <input id="ldap_dn" size="40" name="ldap_base_dn" value="<?php echo htmlspecialchars($ldap_basedn); ?>">
286
  </dd>
322
  </dd>
287
</dl>
323
</dl>
288
<dl>
324
<dl>
289
  <dt>
325
  <dt>
290
    <label for="ldap_filter"><?php echo $l_ldap_filter_label; ?></label>
326
    <label for="ldap_filter"><?php echo $l_ldap_filter_label; ?></label>
291
    <br>
327
    <br>
292
    <?php echo $l_ldap_filter_text; ?></dt>
328
    <?php echo $l_ldap_filter_text; ?></dt>
293
  <dd>
329
  <dd>
294
    <input id="ldap_filter" size="40" name="ldap_filter" value="<?php echo htmlspecialchars($ldap_filter); ?>">
330
    <input id="ldap_filter" size="40" name="ldap_filter" value="<?php echo htmlspecialchars($ldap_filter); ?>">
295
  </dd>
331
  </dd>
296
</dl>
332
</dl>
297
<dl>
333
<dl>
298
  <dt>
334
  <dt>
299
    <label for="ldap_base_filter"><?php echo $l_ldap_base_filter_label; ?></label>
335
    <label for="ldap_base_filter"><?php echo $l_ldap_base_filter_label; ?></label>
300
    <br>
336
    <br>
301
    <?php echo $l_ldap_base_filter_text; ?></dt>
337
    <?php echo $l_ldap_base_filter_text; ?></dt>
302
  <dd>
338
  <dd>
303
    <input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?php echo htmlspecialchars($ldap_base_filter); ?>">
339
    <input id="ldap_base_filter" size="40" name="ldap_base_filter" value="<?php echo htmlspecialchars($ldap_base_filter); ?>">
304
  </dd>
340
  </dd>
305
</dl>
341
</dl>
306
<dl>
342
<dl>
307
  <dt>
343
  <dt>
308
    <label for="ldap_user"><?php echo $l_ldap_user_label; ?></label>
344
    <label for="ldap_user"><?php echo $l_ldap_user_label; ?></label>
309
    <br>
345
    <br>
310
    <?php echo $l_ldap_user_text; ?></dt>
346
    <?php echo $l_ldap_user_text; ?></dt>
311
  <dd>
347
  <dd>
312
    <input id="ldap_user" size="40" name="ldap_user" value="<?php echo htmlspecialchars($ldap_identity); ?>">
348
    <input id="ldap_user" size="40" name="ldap_user" value="<?php echo htmlspecialchars($ldap_identity); ?>">
313
  </dd>
349
  </dd>
314
</dl>
350
</dl>
315
<dl>
351
<dl>
316
  <dt>
352
  <dt>
317
    <label for="ldap_password"><?php echo $l_ldap_password_label; ?></label>
353
    <label for="ldap_password"><?php echo $l_ldap_password_label; ?></label>
318
    <br>
354
    <br>
319
    <?php echo $l_ldap_password_text; ?></dt>
355
    <?php echo $l_ldap_password_text; ?></dt>
320
  <dd>
356
  <dd>
321
    <input id="ldap_password" type="password" size="40" name="ldap_password" value="<?php echo htmlspecialchars($ldap_password);?>">
357
    <input id="ldap_password" type="password" size="40" name="ldap_password" value="<?php echo htmlspecialchars($ldap_password);?>">
322
  </dd>
358
  </dd>
323
</dl>
359
</dl>
324
<p>
360
<p>
325
  <input id="submit" type="submit" value="<?php echo $l_ldap_submit; ?>" name="submit">
361
  <input id="submit" type="submit" value="<?php echo $l_ldap_submit; ?>" name="submit">
326
 
362
 
327
  <input id="reset" type="reset" value="<?php echo $l_ldap_reset; ?>" name="reset">
363
  <input id="reset" type="reset" value="<?php echo $l_ldap_reset; ?>" name="reset">
328
</p>
364
</p>
329
 
365
 
330
</fieldset>
366
</fieldset>
331
</form>
367
</form>
332
<br>
368
<br>
333
</td></tr>
369
</td></tr>
334
</table>
370
</table>
335
</body>
371
</body>
336
</html>
372
</html>
337
 
373