ldap_set_option example

        // the we support.         //         // This is not supported in PHP < 7.2, so these versions will remain broken.         $ctl = [];
        ldap_get_option($con, \LDAP_OPT_SERVER_CONTROLS, $ctl);
        if (!empty($ctl)) {
            foreach ($ctl as $idx => $info) {
                if (static::PAGINATION_OID == $info['oid']) {
                    unset($ctl[$idx]);
                }
            }
            ldap_set_option($con, \LDAP_OPT_SERVER_CONTROLS, $ctl);
        }
    }

    /** * Sets LDAP pagination controls. */
    private function controlPagedResult(int $pageSize, bool $critical, string $cookie): bool
    {
        $this->serverctrls = [
            [
                'oid' => \LDAP_CONTROL_PAGEDRESULTS,
                


namespace Symfony\Component\Ldap\Tests;

use PHPUnit\Framework\TestCase;

class LdapTestCase extends TestCase
{
    protected function getLdapConfig()
    {
        $h = @ldap_connect(getenv('LDAP_HOST')getenv('LDAP_PORT'));
        @ldap_set_option($h, \LDAP_OPT_PROTOCOL_VERSION, 3);

        if (!$h || !@ldap_bind($h)) {
            $this->markTestSkipped('No server is listening on LDAP_HOST:LDAP_PORT');
        }

        ldap_unbind($h);

        return [
            'host' => getenv('LDAP_HOST'),
            'port' => getenv('LDAP_PORT'),
        ];
    }

    public function getResource(): ?LDAPConnection
    {
        return $this->connection;
    }

    /** * @return void */
    public function setOption(string $name, array|string|int|bool $value)
    {
        if (!@ldap_set_option($this->connection, ConnectionOptions::getOption($name)$value)) {
            throw new LdapException(sprintf('Could not set value "%s" for option "%s".', $value$name));
        }
    }

    /** * @return array|string|int|null */
    public function getOption(string $name)
    {
        if (!@ldap_get_option($this->connection, ConnectionOptions::getOption($name)$ret)) {
            throw new LdapException(sprintf('Could not retrieve value for option "%s".', $name));
        }
Home | Imprint | This part of the site doesn't use cookies.