diff --git a/auth/imap/config.html b/auth/imap/config.html
index 8a6dfb04d18..15d5309e115 100644
--- a/auth/imap/config.html
+++ b/auth/imap/config.html
@@ -16,7 +16,8 @@
-
+
+
|
diff --git a/auth/imap/lib.php b/auth/imap/lib.php
index 1bf4fd46a72..0cc6fe2f8f8 100644
--- a/auth/imap/lib.php
+++ b/auth/imap/lib.php
@@ -7,34 +7,40 @@ function auth_user_login ($username, $password) {
global $CFG;
- switch ($CFG->auth_imaptype) {
- case "imapssl":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl}";
- break;
+ $hosts = split(';', $CFG->auth_imaphost); // Could be multiple hosts
- case "imapcert":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
- break;
+ foreach ($hosts as $host) { // Try each host in turn
- case "imaptls":
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/notls}";
- break;
+ $host = trim($host);
- default:
- $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport}";
+ switch ($CFG->auth_imaptype) {
+ case "imapssl":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/ssl}";
+ break;
+
+ case "imapcert":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
+ break;
+
+ case "imaptls":
+ $host = '{'.$host.":$CFG->auth_imapport/imap/notls}";
+ break;
+
+ default:
+ $host = '{'.$host.":$CFG->auth_imapport}";
+ }
+
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
+
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
-
- if ($connection) {
- imap_close($connection);
- return true;
-
- } else {
- return false;
- }
+ return false; // No match
}
diff --git a/auth/nntp/config.html b/auth/nntp/config.html
index 3cf54ae3511..caf0c3a9d27 100644
--- a/auth/nntp/config.html
+++ b/auth/nntp/config.html
@@ -15,6 +15,7 @@
+
|
diff --git a/auth/nntp/lib.php b/auth/nntp/lib.php
index de0a2d597e0..7fd6836fecc 100644
--- a/auth/nntp/lib.php
+++ b/auth/nntp/lib.php
@@ -8,19 +8,22 @@ function auth_user_login ($username, $password) {
global $CFG;
- $host = "{".$CFG->auth_nntphost.":$CFG->auth_nntpport/nntp}";
+ $hosts = split(';', $CFG->auth_nntphost); // Could be multiple hosts
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
+ foreach ($hosts as $host) { // Try each host in turn
+ $host = '{'.trim($host).":$CFG->auth_nntpport/nntp}";
- if ($connection) {
- imap_close($connection);
- return true;
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
- } else {
- return false;
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
+
+ return false; // No match
}
diff --git a/auth/pop3/config.html b/auth/pop3/config.html
index 1f5acfa623c..103375c348f 100644
--- a/auth/pop3/config.html
+++ b/auth/pop3/config.html
@@ -17,6 +17,7 @@
+
|
diff --git a/auth/pop3/lib.php b/auth/pop3/lib.php
index 5602f0065ed..a383905756a 100644
--- a/auth/pop3/lib.php
+++ b/auth/pop3/lib.php
@@ -7,29 +7,35 @@ function auth_user_login ($username, $password) {
global $CFG;
- switch ($CFG->auth_pop3type) {
- case "pop3":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3}INBOX";
- break;
- case "pop3notls":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/notls}INBOX";
- break;
- case "pop3cert":
- $host = "{".$CFG->auth_pop3host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
- break;
+ $hosts = split(';', $CFG->auth_pop3host); // Could be multiple hosts
+
+ foreach ($hosts as $host) { // Try each host in turn
+
+ $host = trim($host);
+
+ switch ($CFG->auth_pop3type) {
+ case "pop3":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3}INBOX";
+ break;
+ case "pop3notls":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3/notls}INBOX";
+ break;
+ case "pop3cert":
+ $host = '{'.$host.":$CFG->auth_pop3port/pop3/ssl/novalidate-cert}INBOX";
+ break;
+ }
+
+ error_reporting(0);
+ $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+ error_reporting($CFG->debug);
+
+ if ($connection) {
+ imap_close($connection);
+ return true;
+ }
}
- error_reporting(0);
- $connection = imap_open($host, $username, $password, OP_HALFOPEN);
- error_reporting($CFG->debug);
-
- if ($connection) {
- imap_close($connection);
- return true;
-
- } else {
- return false;
- }
+ return false; // No matches found
}
diff --git a/lang/en/auth.php b/lang/en/auth.php
index 6c88a34207e..06edb9fbaf4 100644
--- a/lang/en/auth.php
+++ b/lang/en/auth.php
@@ -40,6 +40,7 @@ $string['auth_ldapextrafields'] = 'These fields are optional. You can choose to
$string['auth_ldaptitle'] = 'Use an LDAP server';
$string['auth_manualdescription'] = 'This method removes any way for users to create their own accounts. All accounts must be manually created by the admin user.';
$string['auth_manualtitle'] = 'Manual accounts only';
+$string['auth_multiplehosts'] = 'Multiple hosts can be specified (eg host1.com;host2.com;host3.com';
$string['auth_nntpdescription'] = 'This method uses an NNTP server to check whether a given username and password is valid.';
$string['auth_nntphost'] = 'The NNTP server address. Use the IP number, not DNS name.';
$string['auth_nntpport'] = 'Server port (119 is the most common)';