function ldap_authentication_corresponding_drupal_user in Lightweight Directory Access Protocol (LDAP) 8.2
Same name and namespace in other branches
- 7.2 ldap_authentication/ldap_authentication.inc \ldap_authentication_corresponding_drupal_user()
given authname, determine if corresponding drupal account exists and is authmapped
1 call to ldap_authentication_corresponding_drupal_user()
- _ldap_authentication_user_login_authenticate_validate in ldap_authentication/
ldap_authentication.inc - user form validation will take care of username, pwd fields this function validates ldap authentication specific
File
- ldap_authentication/
ldap_authentication.inc, line 368 - ldap_authentication helper functions
Code
function ldap_authentication_corresponding_drupal_user($authname, $auth_conf, &$watchdog_tokens) {
$detailed_watchdog_log = config('ldap_help.settings')
->get('watchdog_detail');
if (!($drupal_account = user_load_by_name($authname))) {
$uid = db_query("SELECT uid FROM {authmap} WHERE authname = :authname AND module = 'ldap_user'", array(
':authname' => $authname,
))
->fetchColumn();
$drupal_account = $uid ? user_load($uid) : FALSE;
}
if (is_object($drupal_account)) {
$authmaps = user_get_authmaps($authname);
// $authmaps = user_get_authmaps($name); // patch 1599632
$drupal_account_is_authmapped = isset($authmaps['ldap_user']);
$user_data = $drupal_account->data;
if ($drupal_account->uid == 1 && $detailed_watchdog_log) {
watchdog('ldap_authentication', '%username : Drupal username maps to user 1, so do not authenticate with ldap', $watchdog_tokens, WATCHDOG_DEBUG);
}
elseif ($detailed_watchdog_log) {
watchdog('ldap_authentication', '%username : Drupal User Account found. Continuing on to attempt ldap authentication', $watchdog_tokens, WATCHDOG_DEBUG);
}
}
else {
// account does not exist
$drupal_account_is_authmapped = FALSE;
if ($auth_conf->ldapUser->createLDAPAccounts == FALSE) {
if ($detailed_watchdog_log) {
watchdog('ldap_authentication', '%username : Drupal User Account not found and configuration is set to not create new accounts.', $watchdog_tokens, WATCHDOG_DEBUG);
}
}
if ($detailed_watchdog_log) {
watchdog('ldap_authentication', '%username : Existing Drupal User Account not found. Continuing on to attempt ldap authentication', $watchdog_tokens, WATCHDOG_DEBUG);
}
}
return array(
$drupal_account,
$drupal_account_is_authmapped,
);
}