diff --git a/config-templates/authsources.php b/config-templates/authsources.php index 62cf02864e4679f52ca8eac6bf04a2cc09a91017..1ecc707eb6cf11d4d44389c98013efce78022515 100644 --- a/config-templates/authsources.php +++ b/config-templates/authsources.php @@ -133,6 +133,16 @@ $config = array( */ 'username_organization_method' => 'none', + /* + * Whether the organization should be included as part of the username + * when authenticating. If this is set to TRUE, the username will be on + * the form <username>@<organization identifier>. If this is FALSE, the + * username will be used as the user enters it. + * + * The default is FALSE. + */ + 'include_organization_in_username' => FALSE, + /* * A list of available LDAP servers. * diff --git a/modules/ldap/docs/ldap.txt b/modules/ldap/docs/ldap.txt index 3caa9cc4aaccf8d74fe1eb73d0214e0e90a0c6fb..cd4bb5bca53785e5ae361c00858406dd155b2d5e 100644 --- a/modules/ldap/docs/ldap.txt +++ b/modules/ldap/docs/ldap.txt @@ -131,6 +131,16 @@ and add an entry which uses this module: */ 'username_organization_method' => 'none', + /* + * Whether the organization should be included as part of the username + * when authenticating. If this is set to TRUE, the username will be on + * the form <username>@<organization identifier>. If this is FALSE, the + * username will be used as the user enters it. + * + * The default is FALSE. + */ + 'include_organization_in_username' => FALSE, + /* * A list of available LDAP servers. * diff --git a/modules/ldap/lib/Auth/Source/LDAPMulti.php b/modules/ldap/lib/Auth/Source/LDAPMulti.php index 4c56749f51596100a28479ea95704dafa8fef10c..45356946bb9134736a8e87cc3f7746ca04d78fa8 100644 --- a/modules/ldap/lib/Auth/Source/LDAPMulti.php +++ b/modules/ldap/lib/Auth/Source/LDAPMulti.php @@ -23,6 +23,11 @@ class sspmod_ldap_Auth_Source_LDAPMulti extends sspmod_core_Auth_UserPassOrgBase */ private $ldapOrgs; + /** + * Whether we should include the organization as part of the username. + */ + private $includeOrgInUsername; + /** * Constructor for this authentication source. @@ -53,6 +58,12 @@ class sspmod_ldap_Auth_Source_LDAPMulti extends sspmod_core_Auth_UserPassOrgBase continue; } + if ($name === 'include_organization_in_username') { + $this->includeOrgInUsername = $cfgHelper->getBoolean( + 'include_organization_in_username', FALSE); + continue; + } + $orgCfg = $cfgHelper->getArray($name); $orgId = $name; @@ -91,6 +102,10 @@ class sspmod_ldap_Auth_Source_LDAPMulti extends sspmod_core_Auth_UserPassOrgBase throw new SimpleSAML_Error_Error('WRONGUSERPASS'); } + if ($this->includeOrgInUsername) { + $username = $username . '@' . $org; + } + return $this->ldapOrgs[$org]->login($username, $password); }