mirrored from git://git.moodle.org/moodle.git
/
lib.php
43 lines (33 loc) · 1.15 KB
/
lib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?PHP // $Id$
// Authentication by looking up an IMAP server
// This code is completely untested so far - I'm just jotting down ideas ...
// Looks like it should work though ...
$CFG->auth_imaphost = "localhost";
$CFG->auth_imapport = "143"; // 143, 993, 100, 119
$CFG->auth_imaptype = "imap"; // imap, imapssl, pop3, nntp
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 "imap":
$host = "{$CFG->auth_imaphost:$CFG->auth_imapport}INBOX";
break;
case "imapssl":
$host = "{$CFG->auth_imaphost:$CFG->auth_imapport/imap/ssl}INBOX";
break;
case "pop3":
$host = "{$CFG->auth_imaphost:$CFG->auth_imapport/pop3}INBOX";
break;
case "nntp":
$host = "{$CFG->auth_imaphost:$CFG->auth_imapport/nntp}comp.test";
break;
}
if ($connection = imap_open($host, $username, $password)) {
imap_close($connection);
return true;
} else {
return false;
}
}
?>