2002-11-15 08:42:40 +00:00
|
|
|
<?PHP // $Id$
|
2002-11-16 03:49:32 +00:00
|
|
|
// Authentication by looking up an IMAP server
|
2002-11-15 08:42:40 +00:00
|
|
|
|
|
|
|
function auth_user_login ($username, $password) {
|
|
|
|
// Returns true if the username and password work
|
|
|
|
// and false if they are wrong or don't exist.
|
|
|
|
|
|
|
|
global $CFG;
|
|
|
|
|
|
|
|
switch ($CFG->auth_imaptype) {
|
|
|
|
case "imapssl":
|
2002-11-19 08:51:33 +00:00
|
|
|
$host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl}";
|
2002-11-15 08:42:40 +00:00
|
|
|
break;
|
2002-11-17 02:51:36 +00:00
|
|
|
|
2002-11-15 08:59:30 +00:00
|
|
|
case "imapcert":
|
2002-11-19 08:51:33 +00:00
|
|
|
$host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
|
2002-11-15 08:59:30 +00:00
|
|
|
break;
|
2002-11-17 02:51:36 +00:00
|
|
|
|
2002-11-17 15:11:35 +00:00
|
|
|
case "imaptls":
|
2002-11-19 08:51:33 +00:00
|
|
|
$host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/notls}";
|
2002-11-17 15:11:35 +00:00
|
|
|
break;
|
|
|
|
|
2002-11-17 02:51:36 +00:00
|
|
|
default:
|
2002-11-17 09:57:34 +00:00
|
|
|
$host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport}";
|
2002-11-15 08:42:40 +00:00
|
|
|
}
|
|
|
|
|
2002-11-19 08:51:33 +00:00
|
|
|
error_reporting(0);
|
|
|
|
$connection = imap_open($host, $username, $password, OP_HALFOPEN);
|
2002-12-31 08:50:24 +00:00
|
|
|
error_reporting($CFG->debug);
|
2002-11-19 08:51:33 +00:00
|
|
|
|
|
|
|
if ($connection) {
|
2002-11-15 08:42:40 +00:00
|
|
|
imap_close($connection);
|
|
|
|
return true;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|