diff --git a/src/Symfony/Component/Ldap/BaseLdapInterface.php b/src/Symfony/Component/Ldap/BaseLdapInterface.php deleted file mode 100644 index ab247421eb..0000000000 --- a/src/Symfony/Component/Ldap/BaseLdapInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Ldap; - -use Symfony\Component\Ldap\Exception\ConnectionException; - -/** - * Base Ldap interface. - * - * This interface is here for reusability in the BC layer, - * and will be merged in LdapInterface in Symfony 4.0. - * - * @author Charles Sarrazin - * - * @internal - */ -interface BaseLdapInterface -{ - /** - * Return a connection bound to the ldap. - * - * @param string $dn A LDAP dn - * @param string $password A password - * - * @throws ConnectionException If dn / password could not be bound. - */ - public function bind($dn = null, $password = null); - - /** - * Escape a string for use in an LDAP filter or DN. - * - * @param string $subject - * @param string $ignore - * @param int $flags - * - * @return string - */ - public function escape($subject, $ignore = '', $flags = 0); -} diff --git a/src/Symfony/Component/Ldap/LdapClient.php b/src/Symfony/Component/Ldap/LdapClient.php index 3a41c0d58d..bb9c1cbd4c 100644 --- a/src/Symfony/Component/Ldap/LdapClient.php +++ b/src/Symfony/Component/Ldap/LdapClient.php @@ -44,6 +44,22 @@ final class LdapClient implements LdapClientInterface $this->ldap->bind($dn, $password); } + /** + * {@inheritdoc} + */ + public function query($dn, $query, array $options = array()) + { + return $this->ldap->query($dn, $query, $options); + } + + /** + * {@inheritdoc} + */ + public function getEntryManager() + { + return $this->ldap->getEntryManager(); + } + /** * {@inheritdoc} */ diff --git a/src/Symfony/Component/Ldap/LdapClientInterface.php b/src/Symfony/Component/Ldap/LdapClientInterface.php index 2e5d61132d..020e4b5589 100644 --- a/src/Symfony/Component/Ldap/LdapClientInterface.php +++ b/src/Symfony/Component/Ldap/LdapClientInterface.php @@ -21,9 +21,9 @@ namespace Symfony\Component\Ldap; * * @deprecated You should use LdapInterface instead */ -interface LdapClientInterface extends BaseLdapInterface +interface LdapClientInterface extends LdapInterface { - /* + /** * Find a username into ldap connection. * * @param string $dn diff --git a/src/Symfony/Component/Ldap/LdapInterface.php b/src/Symfony/Component/Ldap/LdapInterface.php index 767aa83dd1..f71f7e04f8 100644 --- a/src/Symfony/Component/Ldap/LdapInterface.php +++ b/src/Symfony/Component/Ldap/LdapInterface.php @@ -13,17 +13,28 @@ namespace Symfony\Component\Ldap; use Symfony\Component\Ldap\Adapter\EntryManagerInterface; use Symfony\Component\Ldap\Adapter\QueryInterface; +use Symfony\Component\Ldap\Exception\ConnectionException; /** * Ldap interface. * * @author Charles Sarrazin */ -interface LdapInterface extends BaseLdapInterface +interface LdapInterface { const ESCAPE_FILTER = 0x01; const ESCAPE_DN = 0x02; + /** + * Return a connection bound to the ldap. + * + * @param string $dn A LDAP dn + * @param string $password A password + * + * @throws ConnectionException If dn / password could not be bound. + */ + public function bind($dn = null, $password = null); + /** * Queries a ldap server for entries matching the given criteria. * @@ -39,4 +50,15 @@ interface LdapInterface extends BaseLdapInterface * @return EntryManagerInterface */ public function getEntryManager(); + + /** + * Escape a string for use in an LDAP filter or DN. + * + * @param string $subject + * @param string $ignore + * @param int $flags + * + * @return string + */ + public function escape($subject, $ignore = '', $flags = 0); } diff --git a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php index fa85f68a66..985c09e9c3 100644 --- a/src/Symfony/Component/Ldap/Tests/LdapClientTest.php +++ b/src/Symfony/Component/Ldap/Tests/LdapClientTest.php @@ -54,6 +54,16 @@ class LdapClientTest extends \PHPUnit_Framework_TestCase $this->client->escape('foo', 'bar', 'baz'); } + public function testLdapQuery() + { + $this->ldap + ->expects($this->once()) + ->method('query') + ->with('foo', 'bar', array('baz')) + ; + $this->client->query('foo', 'bar', array('baz')); + } + public function testLdapFind() { $collection = $this->getMock(CollectionInterface::class);