You are here

function _simplesamlphp_auth_get_default_name in simpleSAMLphp Authentication 7.3

Same name and namespace in other branches
  1. 6.3 simplesamlphp_auth.module \_simplesamlphp_auth_get_default_name()
  2. 6.2 simplesamlphp_auth.module \_simplesamlphp_auth_get_default_name()
  3. 7 simplesamlphp_auth.module \_simplesamlphp_auth_get_default_name()
  4. 7.2 simplesamlphp_auth.module \_simplesamlphp_auth_get_default_name()

Gets the default name attribute from the SAML assertion.

Return value

string The name attribute.

1 call to _simplesamlphp_auth_get_default_name()
simplesamlphp_auth_user_insert in ./simplesamlphp_auth.module
Implements hook_user_insert().

File

./simplesamlphp_auth.module, line 483
simpleSAMLphp authentication module for Drupal.

Code

function _simplesamlphp_auth_get_default_name($account) {
  global $_simplesamlphp_auth_as;
  global $_simplesamlphp_auth_saml_attributes;
  $default_name = '';

  // Check if valid local session exists..
  if ($_simplesamlphp_auth_as
    ->isAuthenticated()) {
    $auth_user_name_attr = variable_get('simplesamlphp_auth_user_name', 'eduPersonPrincipalName');
    if (!isset($_simplesamlphp_auth_saml_attributes[$auth_user_name_attr]) || !isset($_simplesamlphp_auth_saml_attributes[$auth_user_name_attr][0]) || $_simplesamlphp_auth_saml_attributes[$auth_user_name_attr][0] == '') {
      throw new Exception(t('There was no set attribute named "%auth_user_name_attr" returned for user %uid.', array(
        '%auth_user_name_attr' => $auth_user_name_attr,
        '%uid' => $account,
      )));
    }
    $default_name = $_simplesamlphp_auth_saml_attributes[$auth_user_name_attr][0];
  }
  return $default_name;
}