I want to set up an LDAP connection. But when validating the user, my log shows me:
Authenticator failed. {"exception":"[object] (Symfony\Component\Security\Core\Exception\BadCredentialsException(code: 0): The presented password is invalid. at C:\Users\mf\PhpstormProjects\poc-ldap\vendor\symfony\ldap\Security\CheckLdapCredentialsListener.php:104)","authenticator":"Symfony\Component\Ldap\Security\LdapAuthenticator"} []
My configuration :
Services.yaml :
parameters:
services:
_defaults:
autowire: true
autoconfigure: true
App\:
resource: '../src/'
exclude:
- '../src/DependencyInjection/'
- '../src/Entity/'
- '../src/Kernel.php'
Symfony\Component\Ldap\Ldap:
arguments:
- '@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter'
tags:
- ldap
Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
arguments:
- host: s.co.lan
port: 389
options:
protocol_version: 3
referrals: false
monolog.logger.ldap:
class: Psr\Log\LoggerInterface
arguments: [ '@monolog.logger.ldap' ]
tags:
- { name: monolog.logger, channel: ldap }
Security.yaml :
security:
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
providers:
my_ldap:
ldap:
service: Symfony\Component\Ldap\Ldap
base_dn: OU=UTILISATEURS,OU=CO,DC=co,DC=lan
search_dn: '[email protected]'
search_password: password
default_roles: ROLE_USER
uid_key: mail
firewalls:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
api_login:
pattern: ^/api/admin/login
stateless: true
json_login_ldap:
check_path: /api/admin/login
login_path: /api/admin/login
service: Symfony\Component\Ldap\Ldap
dn_string: 'mail={username},OU=UTILISATEURS,OU=CO,DC=co,DC=lan'
I also did a test in a specific controller: '$this->ldap->bind($userName, $password);' it works.