With LdapUserProvider i have some errors when i try to load my user.
In this method :
public function loadUserByIdentifier(string $identifier): UserInterface
{
try {
$this->ldap->bind($this->searchDn, $this->searchPassword);
} catch (InvalidCredentialsException) {
throw new InvalidSearchCredentialsException();
}
$identifier = $this->ldap->escape($identifier, '', LdapInterface::ESCAPE_FILTER);
$query = str_replace('{username}', '{user_identifier}', $this->defaultSearch, $replaceCount);
if ($replaceCount > 0) {
trigger_deprecation('symfony/ldap', '6.2', 'Using "{username}" parameter in LDAP configuration is deprecated, consider using "{user_identifier}" instead.');
}
$query = str_replace('{user_identifier}', $identifier, $query);
$search = $this->ldap->query($this->baseDn, $query, ['filter' => 0 == count($this->extraFields) ? '*' : $this->extraFields]);
$entries = $search->execute();
$count = count($entries);
if (!$count) {
$e = new UserNotFoundException(sprintf('User "%s" not found.', $identifier));
$e->setUserIdentifier($identifier);
throw $e;
}
if ($count > 1) {
$e = new UserNotFoundException('More than one user found.');
$e->setUserIdentifier($identifier);
throw $e;
}
$entry = $entries[0];
try {
if (null !== $this->uidKey) {
$identifier = $this->getAttributeValue($entry, $this->uidKey);
}
} catch (InvalidArgumentException) {
}
dd($entry);
return $this->loadUser($identifier, $entry);
}
my dd() gave me an array with my users Ldpa’s attributes like this :
LdapUserProvider.php on line 110: SymfonyComponentLdapEntry {#394 ▼ -dn: "CN=test test,OU=WORK,OU=USER,DC=DOMAIN,DC=COM"-attributes: array:48 [▼
“objectClass” => array:4 [▶]
“cn” => array:1 [▶]
“sn” => array:1 [▶]
“title” => array:1 [▶]
“description” => array:1 [▶]
“givenName” => array:1 [▶]
“initials” => array:1 [▶]
“distinguishedName” => array:1 [▶]
“instanceType” => array:1 [▶]
“whenCreated” => array:1 [▶]
“whenChanged” => array:1 [▶]
“displayName” => array:1 [▶]
“uSNCreated” => array:1 [▶]
“memberOf” => array:17 [▶]
Thats fine.
But, if i comment dd(), the method give me an error :
Could not complete search with dn "dc=DOMAIN,dc=COM", query "(sAMAccountName=test)" and filters "*". LDAP error was [1] Operations error.
On this line :
$entries = $search->execute();
Any idea is appreciated