@@ -246,7 +246,7 @@ Authenticating against an LDAP server can be done using either the form
246246login or the HTTP Basic authentication providers.
247247
248248They 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
251251service
252252.......
@@ -273,6 +273,19 @@ For example, if your users have DN strings in the form
273273Examples 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+
276289Configuration 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