mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
UNTESTED changes to allow multiple hosts to be used for POP3/IMAP/NNTP authentication
Please test them.
This commit is contained in:
parent
b78eabdcdd
commit
f95ad4b43a
@ -16,7 +16,8 @@
|
||||
<?php if (isset($err["auth_imaphost"])) formerr($err["auth_imaphost"]); ?>
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_imaphost","auth") ?>
|
||||
<?php print_string("auth_imaphost","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,6 +15,7 @@
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_nntphost","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
</TD>
|
||||
<TD>
|
||||
<?php print_string("auth_pop3host","auth") ?>
|
||||
<?php print_string("auth_multiplehosts","auth") ?>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
||||
|
@ -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)';
|
||||
|
Loading…
x
Reference in New Issue
Block a user