Skip to content
Snippets Groups Projects
Commit 116aa447 authored by Olav Morken's avatar Olav Morken
Browse files

ldapstatus: Do a connect-test to all ip-addresses for a hostname.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1756 44740490-163a-0410-bde0-09ae8108e29a
parent 0d017361
No related branches found
No related tags found
No related merge requests found
......@@ -96,14 +96,25 @@ class sspmod_ldapstatus_Tester {
return array(FALSE, 'No IP address found for host ' . $host . '.');
}
$timeout = 1.0;
$socket = @fsockopen($host, $port, $errno, $errstr, $timeout);
if ($socket) @fclose($socket);
if ($errno) {
return array(FALSE, $errno . ':' . $errstr . ' [' . $host . ':' . $port . ']');
} else {
return array(TRUE,'');
$errors = array();
foreach ($ips as $ip) {
$timeout = 1.0;
$socket = @fsockopen($ip, $port, $errno, $errstr, $timeout);
if ($errno) {
$errors[] = $errno . ':' . $errstr . ' (' . $host . '[' . $ip . ']:' . $port . ')';
} elseif ($socket === FALSE) {
$errors[] = '[Unknown error, check log] (' . $host . '[' . $ip . ']:' . $port . ')';
} else {
@fclose($socket);
}
}
if (count($errors) === 0) {
return array(TRUE, count($ips) . ' LDAP servers working.');
}
$error = count($errors) . ' of ' . count($ips) . ' failed: '. implode(';', $errors);
return array(FALSE, $error);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment