Subversion Repositories ALCASAR

Rev

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

Rev 1160 Rev 1395
Line 44... Line 44...
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";
Line 72... Line 74...
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
 
Line 151... Line 155...
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 {
Line 165... Line 169...
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 {
-
 
180
					ldap_unbind($ldapconn);
-
 
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 {
170
				ldap_unbind($ldapconn);
195
				ldap_unbind($ldapconn);
171
				return 1;
196
				return 1;
-
 
197
					}
172
			} else {
198
				} else {
173
				// LDAP Bind failed
199
					// LDAP Bind failed
174
				return 0;
200
					return 0;
-
 
201
				}
175
			}
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		*
Line 229... Line 257...
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>";
Line 241... Line 270...
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>";