Skip to content

Commit

Permalink
fix(api): fix the local register journey while using LDAP (#303)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLicense authored Sep 3, 2024
1 parent d1eb15f commit 2791b9c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/api/module/Auth/src/Adapter/LdapAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 6 additions & 0 deletions app/api/module/Auth/src/Adapter/LdapAdapterFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 2791b9c

Please sign in to comment.