feature #27850 [Security] Allow passing null as $filter in LdapUserProvider to get the default filter (louhde)

This PR was merged into the 4.2-dev branch.

Discussion
----------

[Security] Allow passing null as $filter in LdapUserProvider to get the default filter

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Commits
-------

c6f87c6e3a [Security] Allow passing null as $filter in LdapUserProvider to get the default filter
This commit is contained in:
Nicolas Grekas 2018-07-07 16:48:49 +02:00
commit fbb1f828a6
2 changed files with 6 additions and 1 deletions

View File

@ -11,6 +11,7 @@ CHANGELOG
custom anonymous and remember me token classes is deprecated. To
use custom tokens, extend the existing `Symfony\Component\Security\Core\Authentication\Token\AnonymousToken`
or `Symfony\Component\Security\Core\Authentication\Token\RememberMeToken`.
* allow passing null as $filter in LdapUserProvider to get the default filter
4.1.0
-----

View File

@ -35,12 +35,16 @@ class LdapUserProvider implements UserProviderInterface
private $defaultSearch;
private $passwordAttribute;
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = array(), ?string $uidKey = 'sAMAccountName', string $filter = '({uid_key}={username})', string $passwordAttribute = null)
public function __construct(LdapInterface $ldap, string $baseDn, string $searchDn = null, string $searchPassword = null, array $defaultRoles = array(), string $uidKey = null, string $filter = null, string $passwordAttribute = null)
{
if (null === $uidKey) {
$uidKey = 'sAMAccountName';
}
if (null === $filter) {
$filter = '({uid_key}={username})';
}
$this->ldap = $ldap;
$this->baseDn = $baseDn;
$this->searchDn = $searchDn;