summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2013-07-30 10:20:12 (GMT)
committerAleksander Machniak <alec@alec.pl>2013-07-30 10:20:12 (GMT)
commit9c8205826fd4635f48de7f3f60fffcf4b5b8d08f (patch)
treec4f5807d9be71fca7a964cda7fd0263b98f4c080
parentea0ad858e7905f17e8f851905f90cf484332eb7e (diff)
downloadNet_LDAP3-9c8205826fd4635f48de7f3f60fffcf4b5b8d08f.tar.gz
Support <, >, <=, >= operators in searches
-rw-r--r--lib/Net/LDAP3.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index 8b46d85..0dc2961 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -1525,7 +1525,9 @@ class Net_LDAP3
return null;
}
- $filter = '';
+ $operators = array('=', '>', '<', '>=', '<=');
+ $filter = '';
+
foreach ((array) $search['params'] as $field => $param) {
switch ((string)$param['type']) {
case 'prefix':
@@ -1537,6 +1539,11 @@ class Net_LDAP3
$suffix = '';
break;
case 'exact':
+ case '=':
+ case '>':
+ case '<':
+ case '>=':
+ case '<=':
$prefix = '';
$suffix = '';
break;
@@ -1547,17 +1554,19 @@ class Net_LDAP3
break;
}
+ $operator = $param['type'] && in_array($param['type'], $operators) ? $param['type'] : '=';
+
if (is_array($param['value'])) {
$val_filter = array();
foreach ($param['value'] as $val) {
$value = self::_quote_string($val);
- $val_filter[] = "($field=$prefix" . $value . "$suffix)";
+ $val_filter[] = "(" . $field . $operator . $prefix . $value . $suffix . ")";
}
$filter .= "(|" . implode($val_filter, '') . ")";
}
else {
$value = self::_quote_string($param['value']);
- $filter .= "($field=$prefix" . $value . "$suffix)";
+ $filter .= "(" . $field . $operator . $prefix . $value . $suffix . ")";
}
}