Fix LDAP DN concatenation, allow to define a search base

This commit is contained in:
Thomas Gelf 2014-02-14 14:38:52 +00:00
parent 7a02d278ce
commit 9647c37516
3 changed files with 20 additions and 2 deletions

View File

@ -235,9 +235,10 @@ class Connection
// We do not support pagination right now, and there is no chance to
// do so for PHP < 5.4. Warnings about "Sizelimit exceeded" will
// therefore not be hidden right now.
$base = $query->hasBase() ? $query->getBase() : $this->root_dn;
$results = @ldap_search(
$this->ds,
$this->root_dn,
$base,
(string) $query,
$fields,
0, // Attributes and values

View File

@ -90,6 +90,6 @@ class Node extends Root
*/
public function getDN()
{
return $this->parent->getDN() . '.' . $this->getRDN();
return $this->getRDN() . ',' . $this->parent->getDN();
}
}

View File

@ -30,6 +30,7 @@ class Query
protected $limit_offset;
protected $sort_columns = array();
protected $count;
protected $base;
/**
* Constructor
@ -42,6 +43,22 @@ class Query
$this->connection = $connection;
}
public function setBase($base)
{
$this->base = $base;
return $this;
}
public function hasBase()
{
return $this->base !== null;
}
public function getBase()
{
return $this->base;
}
/**
* Count result set, ignoring limits
*