symfony: LDAP Form Authentication dn_string substitution broken?
| Q | A |
|---|---|
| Bug report? | yes |
| Feature request? | no |
| BC Break report? | ??? |
| RFC? | no |
| Symfony version | 3.4 |
| Due to deprecation warnings I replaced stuff in security/firewalls, security/providers. | |
| Actually the substitutuion of ‘{username}’ in dn_string of the firewalls doesn’t seem to have any effect anymore. |
https://symfony.com/doc/3.4/security/ldap.html suggests the following:
# app/config/security.yml
security:
# ...
firewalls:
main:
# ...
form_login_ldap:
# ...
service: Symfony\Component\Ldap\Ldap
dn_string: 'uid={username},dc=example,dc=com'
if I place
dn_string: 'CN={username},OU=Users,DC=my,DC=domain,DC=de'
{username} won’t be replaced.
see the Exception:
LdapException
HTTP 500 Internal Server Error
Could not complete search with dn "CN={username},OU=Users,DC=my,DC=domain,DC=de", query "(&(memberof:1.2.840.113556.1.4.1941:=CN=MyGroup,OU=Groups,DC=my,DC=domain,DC=de))" and filters "*".
Looking at the code there is something different happening to dn_string then to query_string.
For now I’m fine with removing CN={username}, from the config, but either it’s a bug/issue or a wrong documentation.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 15 (12 by maintainers)
and maybe a PR on better validation of the config too
would be great if the result of this discussion would be a PR on the docs
@Pocketstealer You forgot to add the
dn_stringin your configuration, which is required.How this works:
dn_string, the{username}placeholder is replaced by the actual username provided by the user in the form or http basic prompt. No prior search will be performed before binding the LDAP username.dn_stringandquery_string:dn_stringas its base DNquery_stringas the actual query{username}placeholder will only be replaced inquery_stringthere, meaning that you should not use{username}in thedn_string, and you must override that value (its default value is actually{username}so of course, that won’t work.In any case, I do agree that this feature is not perfect by any means, is poorly documented (actually, it is still not documented). But you are always free to contribute (to either the docs or the component itself) and solve it in a more elegant way 😃