You are here

function ldap_sso_user in LDAP Single Sign On 6

Implementation of hook_user().

File

./ldap_sso.module, line 7

Code

function ldap_sso_user($op, &$edit, &$account, $category = NULL) {
  switch ($op) {
    case 'load':
      if ($account->uid == 0 && $GLOBALS['user']->uid == $account->uid) {
        if (!isset($_COOKIE['seamless_login']) || $_COOKIE['seamless_login'] == 'auto login') {
          if (arg(0) == 'user' && !is_numeric(arg(1)) || arg(0) == 'logout' || (arg(0) == 'node' && arg(1) == 'add' || arg(0) == 'node' && arg(2) == 'edit') && $_POST['op'] == 'Preview') {
            return;
          }
          else {
            if (variable_get('ldap_sso_seamless_login', 0) == 1 && $_COOKIE['seamless_login_attempted'] != 'true') {
              setcookie("seamless_login_attempted", 'true', time() + variable_get('ldap_sso_cookie_expire', 315360000), base_path(), "");
              $_SESSION['seamless_login_attempted'] = $_COOKIE['seamless_login_attempted'];
              $destination = 'destination=' . rawurlencode($_GET['q']);
              drupal_goto('user/login/sso', $destination);
            }
            else {
              return;
            }
          }
        }
      }
      break;
    case 'logout':
      if (variable_get('ldap_sso_seamless_login', 0) == 1) {
        setcookie("seamless_login", 'do not auto login', time() + variable_get('ldap_sso_cookie_expire', 315360000), base_path(), "");
        $_SESSION['seamless_login'] = $_COOKIE['seamless_login'];
      }
      break;
  }
}