Revision: 1756
Author: olavmrk
Date: Tue Sep 15 01:30:55 2009
Log: ldapstatus: Do a connect-test to all ip-addresses for a hostname.
http://code.google.com/p/simplesamlphp/source/detail?r=1756

Modified:
  /trunk/modules/ldapstatus/lib/Tester.php

=======================================
--- /trunk/modules/ldapstatus/lib/Tester.php    Tue Sep 15 01:30:46 2009
+++ /trunk/modules/ldapstatus/lib/Tester.php    Tue Sep 15 01:30:55 2009
@@ -96,14 +96,25 @@
                        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);
        }



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"simpleSAMLphp commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/simplesamlphp-commits?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to