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 { ...@@ -96,14 +96,25 @@ class sspmod_ldapstatus_Tester {
return array(FALSE, 'No IP address found for host ' . $host . '.'); return array(FALSE, 'No IP address found for host ' . $host . '.');
} }
$timeout = 1.0; $errors = array();
$socket = @fsockopen($host, $port, $errno, $errstr, $timeout); foreach ($ips as $ip) {
if ($socket) @fclose($socket); $timeout = 1.0;
if ($errno) { $socket = @fsockopen($ip, $port, $errno, $errstr, $timeout);
return array(FALSE, $errno . ':' . $errstr . ' [' . $host . ':' . $port . ']'); if ($errno) {
} else { $errors[] = $errno . ':' . $errstr . ' (' . $host . '[' . $ip . ']:' . $port . ')';
return array(TRUE,''); } 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