You are here

function _simplesamlphp_auth_get_authname in simpleSAMLphp Authentication 7.3

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

Gets the authname attribute from the SAML assertion.

Return value

string The authname attribute.

Throws

Exception Throws an exception if no valid unique id attribute is set in SAML session.

2 calls to _simplesamlphp_auth_get_authname()
simplesamlphp_auth_user_insert in ./simplesamlphp_auth.module
Implements hook_user_insert().
_simplesaml_auth_login_register in ./simplesamlphp_auth.inc
Performs login and/or register actions for SAML authenticated users.

File

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

Code

function _simplesamlphp_auth_get_authname() {
  global $_simplesamlphp_auth_saml_attributes;
  $authname = '';

  // Check if valid local session exists.
  if (isset($_simplesamlphp_auth_saml_attributes)) {
    if (variable_get('simplesamlphp_auth_debug', 0)) {
      watchdog('simplesamlphp_auth', '_simplesamlphp_auth_get_authname: Valid local SAML session exists', NULL, WATCHDOG_DEBUG);
    }
    if (isset($_simplesamlphp_auth_saml_attributes[variable_get('simplesamlphp_auth_unique_id', 'eduPersonPrincipalName')])) {
      $authname = $_simplesamlphp_auth_saml_attributes[variable_get('simplesamlphp_auth_unique_id', 'eduPersonPrincipalName')][0];
    }
    else {
      throw new Exception(t('Error in simplesamlphp_auth.module: no valid unique id attribute set.'));
    }
  }
  return $authname;
}