diff --git a/config/module.config.php b/config/module.config.php index da392d13a35ae4bd9abf2a4120ed8d0e3c598213..35964316df3aeb5f0eb530fa9b6030feffe6d9d4 100644 --- a/config/module.config.php +++ b/config/module.config.php @@ -18,6 +18,11 @@ $settings = [ 200 => 'UnicaenAuth\Provider\Identity\Db', // en 2e 100 => 'UnicaenAuth\Provider\Identity\Ldap', // en 3e @deprecated ], + + /** + * Attribut LDAP utilisé pour le username des utilisateurs + */ + 'ldap_username' => 'supannaliaslogin', ]; return [ diff --git a/config/unicaen-auth.global.php.dist b/config/unicaen-auth.global.php.dist index 4e857772af6eeb5884f556fcd8bc19884ec7f00f..b92e8cad1f7755c1894e4db12288a30668e3cc27 100644 --- a/config/unicaen-auth.global.php.dist +++ b/config/unicaen-auth.global.php.dist @@ -15,6 +15,12 @@ $settings = [ 'enable_privileges' => true, 'entity_manager_name' => 'doctrine.entitymanager.orm_default', // nom du gestionnaire d'entités à utiliser + + /** + * Attribut LDAP utilisé pour le username des utilisateurs + * A personnaliser au besoin + */ + //'ldap_username' => 'supannaliaslogin', ]; $config = [ diff --git a/src/UnicaenAuth/Options/ModuleOptions.php b/src/UnicaenAuth/Options/ModuleOptions.php index 4d3b5fb5570b353bda22c0e452f6d71517ed6cc1..0ce96ee961de6ca1cd6b6252199505f3759519c4 100644 --- a/src/UnicaenAuth/Options/ModuleOptions.php +++ b/src/UnicaenAuth/Options/ModuleOptions.php @@ -19,6 +19,11 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions */ protected $saveLdapUserInDatabase = false; + /** + * @var string + */ + protected $ldapUsername; + /** * @var array */ @@ -33,7 +38,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions * @var string */ protected $entityManagerName = 'doctrine.entitymanager.orm_default'; - + /** * set usernames allowed to make usurpation * @@ -72,7 +77,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions return $this; } - + /** * Retourne la valeur du flag spécifiant si l'utilisateur authentifié doit être * enregistré dans la base de données de l'appli @@ -83,7 +88,33 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { return $this->saveLdapUserInDatabase; } - + + + + /** + * @return string + */ + public function getLdapUsername() + { + return $this->ldapUsername; + } + + + + /** + * @param string $ldapUsername + * + * @return ModuleOptions + */ + public function setLdapUsername($ldapUsername) + { + $this->ldapUsername = $ldapUsername; + + return $this; + } + + + /** * set cas connection params * @@ -97,7 +128,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions return $this; } - + /** * get cas connection params * @@ -107,7 +138,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { return $this->cas; } - + /** * set shibboleth connection params * @@ -131,7 +162,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { return $this->shibboleth; } - + /** * @return string */ @@ -139,7 +170,7 @@ class ModuleOptions extends \ZfcUser\Options\ModuleOptions { return $this->entityManagerName; } - + /** * @param string $entityManagerName * diff --git a/src/UnicaenAuth/Service/User.php b/src/UnicaenAuth/Service/User.php index 7b020a6ec310a2da821b443b4956ea9cd17a5797..c1a483d607d4ef4e582df4bbe7c9a14c71768d4f 100644 --- a/src/UnicaenAuth/Service/User.php +++ b/src/UnicaenAuth/Service/User.php @@ -64,7 +64,7 @@ class User implements ServiceLocatorAwareInterface, EventManagerAwareInterface switch (true) { case $userData instanceof People: - $username = $userData->getSupannAliasLogin(); + $username = $userData->getData($this->getOptions()->getLdapUsername()); $email = $userData->getMail(); $password = 'ldap'; $state = in_array('deactivated', ldap_explode_dn($userData->getDn(), 1)) ? 0 : 1;