You are here

function simplesamlphp_auth_get_attributes in simpleSAMLphp Authentication 7.2

Same name and namespace in other branches
  1. 7.3 simplesamlphp_auth.inc \simplesamlphp_auth_get_attributes()

Return any attributes provided by the SAML IDP.

Parameters

string $attribute: The attribute whose value to return. Can be skipped if all attribute values are requested.

Return value

array If an attribute was provided, the value of the attribute is returned. Otherwise, an array of all attribute values is returned, keyed by attribute.

File

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

Code

function simplesamlphp_auth_get_attributes($attribute = NULL) {
  global $_simplesamlphp_auth_saml_attributes;
  if (isset($attribute)) {

    // Initially, assume that there's nothing to return.
    $result = NULL;

    // If the specified attribute is set, grab it.
    if (isset($_simplesamlphp_auth_saml_attributes)) {
      if (isset($_simplesamlphp_auth_saml_attributes[$attribute])) {
        $result = $_simplesamlphp_auth_saml_attributes[$attribute];
      }
    }
  }
  else {

    // Initially, assume that there's nothing to return.
    $result = array();

    // If the global array exists, return it.
    if (isset($_simplesamlphp_auth_saml_attributes)) {
      $result = $_simplesamlphp_auth_saml_attributes;
    }
  }

  // Return whatever we've got.
  return $result;
}