diff --git a/src/Ldap/LdapManager.php b/src/Ldap/LdapManager.php index b3ed97f4..5679352a 100644 --- a/src/Ldap/LdapManager.php +++ b/src/Ldap/LdapManager.php @@ -157,7 +157,7 @@ class LdapManager return $this->driver->search( $roleParameter['baseDn'], - sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], $dn), + sprintf('(&%s(%s=%s))', $filter, $roleParameter['userDnAttribute'], ldap_escape($dn, null, LDAP_ESCAPE_FILTER)), [$roleParameter['nameAttribute']] ); } diff --git a/tests/Ldap/LdapManagerTest.php b/tests/Ldap/LdapManagerTest.php index 72cc0ae0..380e788c 100644 --- a/tests/Ldap/LdapManagerTest.php +++ b/tests/Ldap/LdapManagerTest.php @@ -356,11 +356,11 @@ class LdapManagerTest extends TestCase 'dn' => 'blub', 'uid' => ['Karl-Heinz'], // just some rubbish data - 'blub' => ['dfsdfsdf'], + 'blub' => ['foo'], 'foo' => ['count' => 1, 'bar'], 'bar' => ['count' => 1, 'foo', 'xxx'], 'xxxxxxxx' => ['https://www.example.com'], - 'blub1' => ['dfsdfsdf'], + 'blub1' => ['foo(bar)'], ], 'count' => 1, ], @@ -376,7 +376,7 @@ class LdapManagerTest extends TestCase ['ldap_value' => 'group4', 'role' => 'ROLE_SUPER_ADMIN'], ], ], - '(&(memberuid=dfsdfsdf))' + '(&(memberuid=foo\28bar\29))' ], ]; }