Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     if (null === $this->search) {
         // If the connection is not bound, then we try an anonymous bind.
         if (!$this->connection->isBound()) {
             $this->connection->bind();
         }
         $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['scopen']));
         }
         $this->search = @$func($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $this->options['maxItems'], $this->options['timeout'], $this->options['deref']);
     }
     if (false === $this->search) {
         throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s"', $this->dn, $this->query, implode(',', $this->options['filter'])));
     }
     return new Collection($this->connection, $this);
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     // If the connection is not bound, then we try an anonymous bind.
     if (!$this->connection->isBound()) {
         $this->connection->bind();
     }
     $con = $this->connection->getResource();
     $this->search = ldap_search($con, $this->dn, $this->query, $this->options['filter'], $this->options['attrsOnly'], $this->options['maxItems'], $this->options['timeout'], $this->options['deref']);
     if (!$this->search) {
         throw new LdapException(sprintf('Could not complete search with dn "%s", query "%s" and filters "%s"', $this->dn, $this->query, implode(',', $this->options['filter'])));
     }
     return new Collection($this->connection, $this);
 }
Ejemplo n.º 3
0
 public function __construct(Connection $connection, Query $search)
 {
     $this->connection = $connection->getResource();
     $this->search = $search->getResource();
 }