From 2791b9c1351a17981b6b9266fa2fa90818c1bf9f Mon Sep 17 00:00:00 2001 From: JoshuaLicense Date: Tue, 3 Sep 2024 11:20:42 +0100 Subject: [PATCH] fix(api): fix the local register journey while using LDAP (#303) --- app/api/module/Auth/src/Adapter/LdapAdapter.php | 5 ++++- app/api/module/Auth/src/Adapter/LdapAdapterFactory.php | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/api/module/Auth/src/Adapter/LdapAdapter.php b/app/api/module/Auth/src/Adapter/LdapAdapter.php index 24588645a9..d134dafc70 100644 --- a/app/api/module/Auth/src/Adapter/LdapAdapter.php +++ b/app/api/module/Auth/src/Adapter/LdapAdapter.php @@ -92,7 +92,10 @@ public function resetPassword(string $identifier, string $newPassword): bool */ public function register(string $identifier, string $password, string $email, array $attributes = []): void { - $attributes = array_merge(['email' => $email], $attributes); + // The `sn` attribute is required while using the object class `inetOrgPerson`. + // This is a local authentication adapter so the data in the `sn` field isn't important. + $attributes['sn'] = $identifier; + $this->client->register($identifier, $password, $attributes); } diff --git a/app/api/module/Auth/src/Adapter/LdapAdapterFactory.php b/app/api/module/Auth/src/Adapter/LdapAdapterFactory.php index 2d3b059b83..4b3407b8a4 100644 --- a/app/api/module/Auth/src/Adapter/LdapAdapterFactory.php +++ b/app/api/module/Auth/src/Adapter/LdapAdapterFactory.php @@ -12,8 +12,14 @@ class LdapAdapterFactory implements FactoryInterface { public function __invoke(ContainerInterface $container, $requestedName, array $options = null): LdapAdapter { + /** + * @var Client $client + */ $client = $container->get(Client::class); + // Using an object class without a `userAccountControl` attribute. + $client->setUserAccountControlAttribute(null); + return new LdapAdapter($client); } }