You are here

function samlauth_associate_saml_id_with_account in SAML Authentication 7

Ensure that a SAML ID is associated with a given user account.

Parameters

$saml_id:

\Drupal\Core\Session\AccountInterface $account:

2 calls to samlauth_associate_saml_id_with_account()
samlauth_acs in ./samlauth.module
Menu callback for /saml/acs.
samlauth_create_user_from_saml_data in ./samlauth.module
Create a new user from SAML response data.

File

./samlauth.module, line 451
Provides SAML authentication capabilities.

Code

function samlauth_associate_saml_id_with_account($saml_id, $account) {
  $uid = samlauth_find_uid_by_unique_id($saml_id);
  if ($uid == NULL) {
    db_insert('authmap')
      ->fields(array(
      'uid' => $account->uid,
      'authname' => $saml_id,
      'module' => 'samlauth',
    ))
      ->execute();
  }
  else {
    db_update('authmap')
      ->fields(array(
      'uid' => $account->uid,
      'authname' => $saml_id,
      'module' => 'samlauth',
    ))
      ->condition('uid', $account->uid)
      ->condition('module', 'samlauth')
      ->execute();
  }
}