Skip to content

Commit ec7dadc

Browse files
committed
added query_string LDAP config option
1 parent ee31b7f commit ec7dadc

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed

reference/configuration/security.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,17 @@ placeholder will be replaced with the user-provided value (his login).
446446
Depending on your LDAP server's configuration, you may need to override
447447
this value.
448448

449+
query_string
450+
............
451+
452+
**type**: ``string`` **default**: ``null``
453+
454+
This is the string which will be used to query for the DN. The ``{username}``
455+
placeholder will be replaced with the user-provided value (his login).
456+
Depending on your LDAP server's configuration, you will need to override
457+
this value. This setting is only necessary if the users DN cannot be derived
458+
statically using the `dn_string` config option.
459+
449460
User provider
450461
~~~~~~~~~~~~~
451462

security/ldap.rst

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ Authenticating against an LDAP server can be done using either the form
246246
login or the HTTP Basic authentication providers.
247247

248248
They are configured exactly as their non-LDAP counterparts, with the
249-
addition of two configuration keys:
249+
addition of two configuration keys and one optional key:
250250

251251
service
252252
.......
@@ -273,6 +273,19 @@ For example, if your users have DN strings in the form
273273
Examples are provided below, for both ``form_login_ldap`` and
274274
``http_basic_ldap``.
275275

276+
query_string
277+
............
278+
279+
**type**: ``string`` **default**: ``null``
280+
281+
This optional key defines the form of the query used in order to search the
282+
DN of the user, from the username. The ``{username}`` string is replaced by
283+
the actual username of the person trying to authenticate.
284+
285+
This setting is only necessary if the users DN cannot be derived statically
286+
using the `dn_string` config option.
287+
288+
276289
Configuration example for form login
277290
....................................
278291

@@ -382,5 +395,66 @@ Configuration example for HTTP Basic
382395
),
383396
);
384397
398+
Configuration example for form login and query_string
399+
.....................................................
400+
401+
.. configuration-block::
402+
403+
.. code-block:: yaml
404+
405+
# app/config/security.yml
406+
security:
407+
# ...
408+
409+
firewalls:
410+
main:
411+
# ...
412+
form_login_ldap:
413+
login_path: login
414+
check_path: login_check
415+
# ...
416+
service: ldap
417+
dn_string: 'dc=example,dc=com'
418+
query_string: '(&(uid={username})(memberOf=cn=users,ou=Services,dc=example,dc=com))'
419+
420+
.. code-block:: xml
421+
422+
<!-- app/config/security.xml -->
423+
<?xml version="1.0" encoding="UTF-8"?>
424+
<srv:container xmlns="http://symfony.com/schema/dic/security"
425+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
426+
xmlns:srv="http://symfony.com/schema/dic/services"
427+
xsi:schemaLocation="http://symfony.com/schema/dic/services
428+
http://symfony.com/schema/dic/services/services-1.0.xsd">
429+
430+
<config>
431+
<firewall name="main">
432+
<form-login-ldap
433+
login-path="login"
434+
check-path="login_check"
435+
service="ldap"
436+
dn-string="dc=example,dc=com"
437+
query-string="(&(uid={username})(memberOf=cn=users,ou=Services,dc=example,dc=com))" />
438+
</firewall>
439+
</config>
440+
</srv:container>
441+
442+
.. code-block:: php
443+
444+
$container->loadFromExtension('security', array(
445+
'firewalls' => array(
446+
'main' => array(
447+
'form_login_ldap' => array(
448+
'login_path' => 'login',
449+
'check_path' => 'login_check',
450+
'service' => 'ldap',
451+
'dn_string' => 'dc=example,dc=com',
452+
'query_string' => '(&(uid={username})(memberOf=cn=users,ou=Services,dc=example,dc=com))',
453+
// ...
454+
),
455+
),
456+
)
457+
);
458+
385459
.. _`RFC4515`: http://www.faqs.org/rfcs/rfc4515.html
386460
.. _`LDAP injection`: http://projects.webappsec.org/w/page/13246947/LDAP%20Injection

0 commit comments

Comments
 (0)