moodle/moodle · error · moodle_exception
shib_not_all_attributes_error
shib_not_all_attributes_error
Error message
shib_not_all_attributes_error
What it means
This Moodle exception is thrown by auth_shibboleth's get_userinfo() when the essential Shibboleth attributes are absent from the $_SERVER superglobal. Specifically, $_SERVER[user_attribute] is empty, meaning the IdP did not deliver the mapped username (and the error message lists the missing firstname/lastname/email mappings too). It guards against building a Moodle user profile from incomplete attribute data.
Solutions
- Check Site administration > Plugins > Authentication > Shibboleth > 'Username mapping' matches an attribute your IdP actually releases (e.g. eppn, persistent-id).
- Verify on the IdP that the attribute-release/attribute-filter policy releases username, firstname, lastname and email to this SP.
- Test what the SP receives: dump $_SERVER on a protected page or check the SP shibd session dump.
- Ensure Apache/Shibboleth actually protects /auth/shibboleth and /login (Request mapping / ShibRequestSetting) so attributes are exposed.
Example fix
// before (auth settings) $username_mapping = 'uid'; // IdP never releases 'uid' // after $username_mapping = 'eppn'; // attribute confirmed released by the IdP
Defensive patterns
Strategy: validation
Validate before calling
function shibAttributesPresent(array $map): bool {
foreach (array_values($map) as $srvKey) {
if (empty($_SERVER[$srvKey])) {
return false;
}
}
return true;
}
// $map = config->user_attribute / field_map_firstname / field_map_lastname / field_map_email Type guard
function hasShibAttribute(string $key): bool {
return isset($_SERVER[$key]) && $_SERVER[$key] !== '';
} Try / catch
try {
$userinfo = $auth->get_userinfo($username);
} catch (\moodle_exception $e) {
if ($e->errorcode === 'shib_not_all_attributes_error') {
debugging('IdP did not release required attributes: ' . $e->debuginfo, DEBUG_DEVELOPER);
// fall back to manual login page
}
throw $e;
} Prevention
- Keep the IdP attribute-release policy in sync with the Moodle Shibboleth field mappings
- After changing 'Username mapping' or field maps, verify the SP actually receives those variables
- Monitor SP logs (shibd) for attribute filtering denials
When it happens
Trigger: Calling get_userinfo() after a Shibboleth login where $_SERVER[$this->config->user_attribute] is empty — the SP did not receive the mapped user_attribute (e.g. 'persistent-id' or 'eppn') from the IdP.
Common situations: IdP not releasing the required attribute (attribute filter/policy mismatch); wrong 'Username mapping' field configured in the Shibboleth auth settings; Shibboleth SP not protecting the Moodle directory so no attributes populate $_SERVER; IdP attribute encoding changes after an upgrade.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- shib_invalid_account_error
- shib_no_attributes_error
- shib_not_set_up_error
- invalidlogin
- ntlmsso_iwamagicnotenabled
AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14).
Data as JSON: /api/errors/f25a06898f6ecf59.
Report an issue: GitHub.
Appendix: source
Thrown at public/auth/shibboleth/auth.php:98
return false;
}
}
/**
* Returns the user information for 'external' users. In this case the
* attributes provided by Shibboleth
*
* @return array $result Associative array of user data
*/
function get_userinfo($username) {
// reads user information from shibboleth attributes and return it in array()
global $CFG;
// Check whether we have got all the essential attributes
if ( empty($_SERVER[$this->config->user_attribute]) ) {
throw new \moodle_exception( 'shib_not_all_attributes_error', 'auth_shibboleth' , '',
"'".$this->config->user_attribute."' ('".$_SERVER[$this->config->user_attribute]."'), '".
$this->config->field_map_firstname."' ('".$_SERVER[$this->config->field_map_firstname]."'), '".
$this->config->field_map_lastname."' ('".$_SERVER[$this->config->field_map_lastname]."') and '".
$this->config->field_map_email."' ('".$_SERVER[$this->config->field_map_email]."')");
}
$attrmap = $this->get_attributes();
$result = array();
$search_attribs = array();
foreach ($attrmap as $key=>$value) {
// Check if attribute is present
if (!isset($_SERVER[$value])){
$result[$key] = '';
continue;
}
View on GitHub (pinned to 48ea8c3322)