You are here

function ldap_sso_user_login in LDAP Single Sign On 6

A proxy function for the actual authentication routine. This is in place so various implementations of grabbing NTLM credentials can be used and selected from an administration page. This is the real gatekeeper since this assumes that any NTLM authentication from the underlying web server is good enough, and only checks that there are values in place for the user name, and anything else that is set for a particular implementation. In the case that there is no credentials set by the underlying web server, the user is redirected to the normal user login form.

Return value

false

1 string reference to 'ldap_sso_user_login'
ldap_sso_menu in ./ldap_sso.module
Implementation of hook_menu().

File

./ldap_sso.module, line 170

Code

function ldap_sso_user_login() {
  $implementation = variable_get('ldap_sso_ldap_implementation', 'mod_auth_sspi');
  switch ($implementation) {
    case 'mod_auth_sspi':
      $remote_user = $_SERVER['REMOTE_USER'] ? $_SERVER['REMOTE_USER'] : $_SERVER['REDIRECT_REMOTE_USER'];
      break;
  }
  if ($remote_user) {
    $user = ldap_sso_authenticate($remote_user);
    if ($user && $user->uid > 0) {
      if (variable_get('ldap_sso_seamless_login', 0) == 1) {
        setcookie("seamless_login", 'auto login', time() + variable_get('ldap_sso_cookie_expire', 315360000), base_path(), "");
        $_SESSION['seamless_login'] = $_COOKIE['seamless_login'];
        setcookie("seamless_login_attempted", '');
        unset($_SESSION['seamless_login_attempted']);
      }
      drupal_set_message(t(theme('ldap_sso_login_message', 'You have been successfully authenticated')));
      drupal_goto('home');
    }
    else {
      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'];
      }
      drupal_set_message(theme('ldap_sso_message_not_found', t('Sorry, your LDAP credentials were not found, ' . 'or the LDAP is not available. You may log in ' . 'with other credentials on the !user_login_form.', array(
        '!user_login_form' => l(t('user login form'), 'user/login'),
      ))), 'error');
      drupal_goto('user/login');
    }
  }
  else {
    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'];
    }
    drupal_set_message(t(theme('ldap_sso_message_not_authenticated', 'You were not authenticated by the server. You may log in with your credentials below.')), 'error');
    drupal_goto('user/login');
  }
}