diff --git a/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php b/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php index 4bba5c2ebee40..25a664c24ece3 100644 --- a/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php +++ b/src/Symfony/Component/Ldap/Adapter/AbstractQuery.php @@ -32,12 +32,12 @@ public function __construct(ConnectionInterface $connection, string $dn, string 'maxItems' => 0, 'sizeLimit' => 0, 'timeout' => 0, - 'deref' => static::DEREF_NEVER, + 'deref' => QueryInterface::DEREF_NEVER, 'attrsOnly' => 0, - 'scope' => static::SCOPE_SUB, + 'scope' => QueryInterface::SCOPE_SUB, )); - $resolver->setAllowedValues('deref', array(static::DEREF_ALWAYS, static::DEREF_NEVER, static::DEREF_FINDING, static::DEREF_SEARCHING)); - $resolver->setAllowedValues('scope', array(static::SCOPE_BASE, static::SCOPE_ONE, static::SCOPE_SUB)); + $resolver->setAllowedValues('deref', array(QueryInterface::DEREF_ALWAYS, QueryInterface::DEREF_NEVER, QueryInterface::DEREF_FINDING, QueryInterface::DEREF_SEARCHING)); + $resolver->setAllowedValues('scope', array(QueryInterface::SCOPE_BASE, QueryInterface::SCOPE_ONE, QueryInterface::SCOPE_SUB)); $resolver->setNormalizer('filter', function (Options $options, $value) { return \is_array($value) ? $value : array($value); diff --git a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php index 05e5878bb2a48..ba658663b463e 100644 --- a/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php +++ b/src/Symfony/Component/Ldap/Adapter/ExtLdap/Query.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Ldap\Adapter\ExtLdap; use Symfony\Component\Ldap\Adapter\AbstractQuery; +use Symfony\Component\Ldap\Adapter\QueryInterface; use Symfony\Component\Ldap\Exception\LdapException; use Symfony\Component\Ldap\Exception\NotBoundException; @@ -62,20 +63,18 @@ public function execute() $con = $this->connection->getResource(); - switch ($this->options['scope']) { - case static::SCOPE_BASE: - $func = 'ldap_read'; - break; - case static::SCOPE_ONE: - $func = 'ldap_list'; - break; - case static::SCOPE_SUB: - $func = 'ldap_search'; - break; - default: - throw new LdapException(sprintf('Could not search in scope "%s".', $this->options['scope'])); + $funcMap = array( + QueryInterface::SCOPE_BASE => 'ldap_read', + QueryInterface::SCOPE_ONE => 'ldap_list', + QueryInterface::SCOPE_SUB => 'ldap_search', + ); + + if (!isset($funcMap[$this->options['scope']])) { + throw new LdapException(sprintf('Could not search in scope "%s".', $this->options['scope'])); } + $func = $funcMap[$this->options['scope']]; + $this->search = @$func( $con, $this->dn,