function ldap_sso_boot in LDAP Single Sign On 7
Same name and namespace in other branches
- 7.2 ldap_sso.module \ldap_sso_boot()
Implements hook_boot(). Perform setup tasks. This entry point is used because hook_user_load no longer runs on anonymous users, and hook_boot is guaranteed to run, regardless of cache
File
- ./
ldap_sso.module, line 47 - This module injects itself into Drupal's Authentication stack.
Code
function ldap_sso_boot() {
if (!drupal_is_cli() && $GLOBALS['user']->uid == 0) {
if (!isset($_COOKIE['seamless_login']) || $_COOKIE['seamless_login'] == 'auto login') {
if (arg(0) == 'user' && !is_numeric(arg(1)) || arg(0) == 'logout') {
return;
}
else {
if (isset($_COOKIE['seamless_login_attempted'])) {
$login_attempted = $_COOKIE['seamless_login_attempted'];
}
else {
$login_attempted = FALSE;
}
require_once DRUPAL_ROOT . '/includes/common.inc';
require_once DRUPAL_ROOT . '/' . variable_get('path_inc', 'includes/path.inc');
$ldap_authentication_conf = variable_get('ldap_authentication_conf', array());
if (isset($ldap_authentication_conf['seamlessLogin']) && $ldap_authentication_conf['seamlessLogin'] == 1 && $login_attempted != 'true') {
setcookie("seamless_login_attempted", 'true', time() + (int) $ldap_authentication_conf['cookieExpire'], base_path(), "");
$_SESSION['seamless_login_attempted'] = $login_attempted;
// removed with http://drupal.org/node/1485118 patch
//$ldap_sso_q = (!isset($_GET['q']) || $_GET['q'] == '') ? 'user' : $_GET['q'];
//drupal_goto('user/login/sso', array('query' => array('destination' => rawurlencode($ldap_sso_q))));
drupal_bootstrap(DRUPAL_BOOTSTRAP_LANGUAGE);
drupal_goto('user/login/sso', array(
'query' => drupal_get_destination(),
));
}
else {
return;
}
}
}
}
}