You are here

function _simplesamlphp_auth_get_default_name in simpleSAMLphp Authentication 6.2

Same name and namespace in other branches
  1. 6.3 simplesamlphp_auth.module \_simplesamlphp_auth_get_default_name()
  2. 7.3 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

The name attribute.

1 call to _simplesamlphp_auth_get_default_name()
simplesamlphp_auth_user in ./simplesamlphp_auth.module
Implementation of hook_user().

File

./simplesamlphp_auth.module, line 646
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])) {
      throw new Exception(t('There was no attribute named %auth_user_name_attr set for your user.', array(
        '%auth_user_name_attr' => $auth_user_name_attr,
      )));
    }
    $default_name = $_simplesamlphp_auth_saml_attributes[$auth_user_name_attr][0];
  }
  return $default_name;
}