Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401]

   1  <?php
   2  
   3  require(__DIR__.'/../../config.php');
   4  
   5  $PAGE->set_url('/auth/ldap/ntlmsso_finish.php');
   6  $PAGE->set_context(context_system::instance());
   7  
   8  // Define variables used in page
   9  $site = get_site();
  10  
  11  $authsequence = get_enabled_auth_plugins(); // Auths, in sequence.
  12  if (!in_array('ldap', $authsequence, true)) {
  13      throw new \moodle_exception('ldap_isdisabled', 'auth');
  14  }
  15  
  16  $authplugin = get_auth_plugin('ldap');
  17  if (empty($authplugin->config->ntlmsso_enabled)) {
  18      throw new \moodle_exception('ntlmsso_isdisabled', 'auth_ldap');
  19  }
  20  
  21  // If ntlmsso_finish() succeeds, then the code never returns,
  22  // so we only worry about failure.
  23  if (!$authplugin->ntlmsso_finish()) {
  24      // Redirect to login, saying "don't try again!"
  25      // Display the page header. This makes redirect respect the timeout we specify
  26      // here (and not add 3 more secs).
  27      $loginsite = get_string("loginsite");
  28      $PAGE->navbar->add($loginsite);
  29      $PAGE->set_title($loginsite);
  30      $PAGE->set_heading($site->fullname);
  31      echo $OUTPUT->header();
  32      redirect($CFG->wwwroot . '/login/index.php?authldap_skipntlmsso=1',
  33               get_string('ntlmsso_failed','auth_ldap'), 3);
  34  }