Adapter example

use Symfony\Component\Ldap\Tests\LdapTestCase;

/** * @requires extension ldap * * @group integration */
class AdapterTest extends LdapTestCase
{
    public function testLdapEscape()
    {
        $ldap = new Adapter();

        $this->assertEquals('\20foo\3dbar\0d(baz)*\20', $ldap->escape(" foo=bar\r(baz)* ", '', LdapInterface::ESCAPE_DN));
    }

    /** * @group functional */
    public function testLdapQuery()
    {
        $ldap = new Adapter($this->getLdapConfig());

        
/** * @requires extension ldap * * @group integration */
class LdapManagerTest extends LdapTestCase
{
    private Adapter $adapter;

    protected function setUp(): void
    {
        $this->adapter = new Adapter($this->getLdapConfig());
        $this->adapter->getConnection()->bind('cn=admin,dc=symfony,dc=com', 'symfony');
    }

    /** * @group functional */
    public function testLdapAddAndRemove()
    {
        $this->executeSearchQuery(1);

        $entry = new Entry('cn=Charles Sarrazin,dc=symfony,dc=com', [
            

    public static function create(string $adapter, array $config = [])static
    {
        if ('ext_ldap' !== $adapter) {
            throw new DriverNotFoundException(sprintf('Adapter "%s" not found. Only "ext_ldap" is supported at the moment.', $adapter));
        }

        return new self(new Adapter($config));
    }
}
Home | Imprint | This part of the site doesn't use cookies.