Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
// Don't let lib/setup.php set any cookies
4
// as we will be executing under the OS security
5
// context of the user we are trying to login, rather than
6
// of the webserver.
7
define('NO_MOODLE_COOKIES', true);
8
 
9
require(__DIR__.'/../../config.php');
10
 
11
$PAGE->set_context(context_system::instance());
12
 
13
$authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
14
if (!in_array('ldap', $authsequence, true)) {
15
    throw new \moodle_exception('ldap_isdisabled', 'auth');
16
}
17
 
18
$authplugin = get_auth_plugin('ldap');
19
if (empty($authplugin->config->ntlmsso_enabled)) {
20
    throw new \moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
21
}
22
 
23
$sesskey = required_param('sesskey', PARAM_RAW);
24
$file = $CFG->dirroot.'/pix/spacer.gif';
25
 
26
if ($authplugin->ntlmsso_magic($sesskey) && file_exists($file)) {
27
    if (!empty($authplugin->config->ntlmsso_ie_fastpath)) {
28
        if (core_useragent::is_ie()) {
29
            redirect($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php');
30
        }
31
    }
32
 
33
    // Serve GIF
34
    // Type
35
    header('Content-Type: image/gif');
36
    header('Content-Length: '.filesize($file));
37
 
38
    // Output file
39
    $handle = fopen($file, 'r');
40
    fpassthru($handle);
41
    fclose($handle);
42
    exit;
43
} else {
44
    throw new \moodle_exception('ntlmsso_iwamagicnotenabled', 'auth_ldap');
45
}
46
 
47