mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-23 05:44:36 +02:00
commit
5d52a54d94
@ -307,7 +307,7 @@ class Connection
|
|||||||
$results = @ldap_search(
|
$results = @ldap_search(
|
||||||
$this->ds,
|
$this->ds,
|
||||||
$base,
|
$base,
|
||||||
(string) $query,
|
$query->create(),
|
||||||
$fields,
|
$fields,
|
||||||
0, // Attributes and values
|
0, // Attributes and values
|
||||||
0 // No limit - at least where possible
|
0 // No limit - at least where possible
|
||||||
@ -619,7 +619,7 @@ class Connection
|
|||||||
$result = @ldap_read(
|
$result = @ldap_read(
|
||||||
$ds,
|
$ds,
|
||||||
'',
|
'',
|
||||||
(string) $query,
|
$query->create(),
|
||||||
$query->listFields()
|
$query->listFields()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
namespace Icinga\Protocol\Ldap;
|
namespace Icinga\Protocol\Ldap;
|
||||||
|
|
||||||
use Icinga\Exception\IcingaException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search class
|
* Search class
|
||||||
*
|
*
|
||||||
@ -84,7 +82,7 @@ class Query
|
|||||||
public function limit($count = null, $offset = null)
|
public function limit($count = null, $offset = null)
|
||||||
{
|
{
|
||||||
if (! preg_match('~^\d+~', $count . $offset)) {
|
if (! preg_match('~^\d+~', $count . $offset)) {
|
||||||
throw new IcingaException(
|
throw new Exception(
|
||||||
'Got invalid limit: %s, %s',
|
'Got invalid limit: %s, %s',
|
||||||
$count,
|
$count,
|
||||||
$offset
|
$offset
|
||||||
@ -302,21 +300,11 @@ class Query
|
|||||||
*
|
*
|
||||||
* @string
|
* @string
|
||||||
*/
|
*/
|
||||||
public function __toString()
|
public function create()
|
||||||
{
|
|
||||||
return $this->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the LDAP filter that will be applied
|
|
||||||
*
|
|
||||||
* @string
|
|
||||||
*/
|
|
||||||
protected function render()
|
|
||||||
{
|
{
|
||||||
$parts = array();
|
$parts = array();
|
||||||
if (! isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) {
|
if (! isset($this->filters['objectClass']) || $this->filters['objectClass'] === null) {
|
||||||
// throw new IcingaException('Object class is mandatory');
|
throw new Exception('Object class is mandatory');
|
||||||
}
|
}
|
||||||
foreach ($this->filters as $key => $value) {
|
foreach ($this->filters as $key => $value) {
|
||||||
$parts[] = sprintf(
|
$parts[] = sprintf(
|
||||||
|
@ -109,10 +109,10 @@ class QueryTest extends BaseTestCase
|
|||||||
$this->assertEquals('testIntColumn', $cols[0][0]);
|
$this->assertEquals('testIntColumn', $cols[0][0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test__toString()
|
public function testCreateQuery()
|
||||||
{
|
{
|
||||||
$select = $this->prepareSelect();
|
$select = $this->prepareSelect();
|
||||||
$res = '(&(objectClass=dummyClass)(testIntColumn=1)(testStringColumn=test)(testWildcard=abc*))';
|
$res = '(&(objectClass=dummyClass)(testIntColumn=1)(testStringColumn=test)(testWildcard=abc*))';
|
||||||
$this->assertEquals($res, (string) $select);
|
$this->assertEquals($res, $select->create());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user