function samlauth_create_user_from_saml_data in SAML Authentication 7
Create a new user from SAML response data.
Parameters
$saml_data:
1 call to samlauth_create_user_from_saml_data()
- samlauth_acs in ./
samlauth.module - Menu callback for /saml/acs.
File
- ./
samlauth.module, line 480 - Provides SAML authentication capabilities.
Code
function samlauth_create_user_from_saml_data($saml_data) {
$user_unique_attribute = variable_get('samlauth_unique_id_attribute');
$user_name_attribute = variable_get('samlauth_user_name_attribute');
$user_mail_attribute = variable_get('samlauth_user_mail_attribute');
if (!isset($saml_data[$user_name_attribute][0])) {
throw new Exception('Missing name attribute in SAML response.');
}
if (!isset($saml_data[$user_mail_attribute][0])) {
throw new Exception('Missing mail attribute in SAML response.');
}
$account = new stdClass();
$account->name = $saml_data[$user_name_attribute][0];
$account->pass = user_password(50);
$account->mail = $saml_data[$user_mail_attribute][0];
$account->status = 1;
// Fix timezone warning when creating new user.
$account->timezone = variable_get('date_default_timezone', 0);
// Allow other modules to change/set user properties before saving.
drupal_alter('samlauth_new_user', $account, $saml_data);
user_save($account);
samlauth_associate_saml_id_with_account($saml_data[$user_unique_attribute][0], $account);
return $account;
}