Skip to content
Advertisement

Symfony Ldap checkPassword

I’m using Symfony 4.4 and I’m doing my own authenticator. Everything works fine, I just can’t figure out how to compare the password entered by the user and the one in Ldap. I would like to do this in the “checkCredentials” method in my LoginFormAuthenticator. Here is my LdapUserProvider:

JavaScript

I first thought about using the getPassword method but it requires and Entry, and I don’t know how to get this Entry. Thanks

Advertisement

Answer

For anyone who might want the same, I actually used

JavaScript

The $dnUser corresponds to the dn of the Entry of the user, you can get it with

JavaScript

And the password is the one entered by the User. It checks if the password entered by the user is the same than the one in the LDAP. If it’s good, nothing happens, but if it’s false it throws an InvalidCredentialsException. So I used it like that:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement