MDL-81574 mod_forum: Fix deprecated usage of format_text
[moodle.git] / auth / ldap / ntlmsso_magic.php
blobbb1847650ef6ae5ecd93cb8e163a4ab62a1f2e76
1 <?php
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);
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');
33 // Serve GIF
34 // Type
35 header('Content-Type: image/gif');
36 header('Content-Length: '.filesize($file));
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');