function cas_user_load_by_name in CAS 7
Same name and namespace in other branches
- 6.3 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.
$reset: TRUE to reset the internal cache and load from the database; FALSE (default) to load from the internal cache, if set.
Return value
A fully-loaded $user object upon successful user load or FALSE if user cannot be loaded.
7 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_batch_user_add in ./
cas.batch.inc - CAS user creation batch callback.
- cas_drush_user_create in ./
cas.drush.inc - Creates a new CAS user account.
File
- ./
cas.module, line 659 - 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, $reset = FALSE) {
if ($alter) {
$cas_user = array(
'name' => $cas_name,
'login' => TRUE,
'register' => FALSE,
);
drupal_alter('cas_user', $cas_user);
$cas_name = $cas_user['name'];
}
$uid = db_select('cas_user')
->fields('cas_user', array(
'uid',
))
->condition('cas_name', db_like($cas_name), 'LIKE')
->range(0, 1)
->execute()
->fetchField();
if ($uid) {
return user_load($uid, $reset);
}
return FALSE;
}