MDL-20697 removing duplicate error string, fixing get_site() which is now using excep...
[moodle.git] / auth / ldap / ntlmsso_finish.php
1 <?php
3 require_once(dirname(dirname(dirname(__FILE__)))."/config.php");
5 //HTTPS is potentially required in this page
6 httpsrequired();
8 $PAGE->set_url(new moodle_url($CFG->wwwroot.'/auth/ldap/ntlmsso_finish.php'));
10 /// Define variables used in page
11 $site = get_site();
13 $authsequence = get_enabled_auth_plugins(true); // auths, in sequence
14 if (!in_array('ldap',$authsequence,true)) {
15     print_error('ldap_isdisabled','auth');
16 }
18 $authplugin = get_auth_plugin('ldap');
19 if (empty($authplugin->config->ntlmsso_enabled)) {
20     print_error('ntlmsso_isdisabled','auth_ldap');
21 }
23 // If ntlmsso_finish() succeeds, then the code never returns,
24 // so we only worry about failure.
25 if (!$authplugin->ntlmsso_finish()) {
26     // Redirect to login, saying "don't try again!"
27     // Display the page header. This makes redirect respect the timeout we specify
28     // here (and not add 3 more secs).
29     $loginsite = get_string("loginsite");
30     $PAGE->navbar->add($loginsite);
31     $PAGE->set_title("$site->fullname: $loginsite");
32     $PAGE->set_heading($site->fullname);
33     echo $OUTPUT->header();
34     redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1', 
35              get_string('ntlmsso_failed','auth_ldap'), 3);
36 }