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
7 define('NO_MOODLE_COOKIES', true);
9 require(__DIR__
.'/../../config.php');
11 $PAGE->set_context(context_system
::instance());
13 $authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
14 if (!in_array('ldap', $authsequence, true)) {
15 throw new \
moodle_exception('ldap_isdisabled', 'auth');
18 $authplugin = get_auth_plugin('ldap');
19 if (empty($authplugin->config
->ntlmsso_enabled
)) {
20 throw new \
moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
23 $sesskey = required_param('sesskey', PARAM_RAW
);
24 $file = $CFG->dirroot
.'/pix/spacer.gif';
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');
35 header('Content-Type: image/gif');
36 header('Content-Length: '.filesize($file));
39 $handle = fopen($file, 'r');
44 throw new \
moodle_exception('ntlmsso_iwamagicnotenabled', 'auth_ldap');