You are here

function cas_user_load_by_name in CAS 6.3

Same name and namespace in other branches
  1. 7 cas.module \cas_user_load_by_name()

Fetch a user object by CAS name.

Parameters

$cas_name: The name of the CAS user.

$alter: If TRUE, run the CAS username through hook_cas_user_alter() before loading the account.

Return value

A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.

6 calls to cas_user_load_by_name()
CasTestHelper::casLogin in ./cas.test
Log in a CAS user with the internal browser.
CasUserAdminTestCase::testCASUserHooks in ./cas.test
Registers, modifies, and deletes a CAS user using User API hooks.
CasUserTestCase::testCasAutoRegister in ./cas.test
Tests automatically registering a user on login.
cas_drush_user_create in ./cas.drush.inc
Creates a new CAS user account.
cas_drush_user_get_users_from_arguments in ./cas.drush.inc
Look up user ids from a comma-separated list of CAS usernames.

... See full list

File

./cas.module, line 548
Enables users to authenticate via a Central Authentication Service (CAS) Cas will currently work if the auto registration is turned on and will create user accounts automatically.

Code

function cas_user_load_by_name($cas_name, $alter = FALSE) {
  if ($alter) {
    $cas_user = array(
      'name' => $cas_name,
      'login' => TRUE,
      'register' => FALSE,
    );
    drupal_alter('cas_user', $cas_user);
    $cas_name = $cas_user['name'];
  }
  $result = db_query("SELECT uid FROM {cas_user} WHERE LOWER(cas_name) = LOWER('%s')", $cas_name);
  if ($uid = db_fetch_array($result)) {
    return user_load($uid);
  }
  return FALSE;
}