Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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      print_error('ldap_isdisabled', 'auth');
  16  }
  17  
  18  $authplugin = get_auth_plugin('ldap');
  19  if (empty($authplugin->config->ntlmsso_enabled)) {
  20      print_error('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      print_error('ntlmsso_iwamagicnotenabled', 'auth_ldap');
  45  }
  46  
  47