summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2014-12-11 18:08:09 (GMT)
committerAleksander Machniak <machniak@kolabsys.com>2014-12-11 18:08:09 (GMT)
commit0f464b8fedd05b7c4f1a58addfadb3806a85a8fe (patch)
treec761e8103a284121007da53f4ec1cf316754814b
parent26773f13a2b4130969ae097481afc68f773a7f7c (diff)
downloadNet_LDAP3-0f464b8fedd05b7c4f1a58addfadb3806a85a8fe.tar.gz
Fix handling of special characters in DN string when searching by entrydn
-rw-r--r--lib/Net/LDAP3.php23
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/Net/LDAP3.php b/lib/Net/LDAP3.php
index 6b03ae7..d46ee20 100644
--- a/lib/Net/LDAP3.php
+++ b/lib/Net/LDAP3.php
@@ -1706,6 +1706,8 @@ class Net_LDAP3
$filter = '';
foreach ((array) $search['params'] as $field => $param) {
+ $value = (array) $param['value'];
+
switch ((string)$param['type']) {
case 'prefix':
$prefix = '';
@@ -1724,6 +1726,13 @@ class Net_LDAP3
case '<=':
$prefix = '';
$suffix = '';
+
+ // this is a common query to find entry by DN, make sure
+ // it is a unified DN so special characters are handled correctly
+ if ($field == 'entrydn') {
+ $value = array_map(array('Net_LDAP3', 'unified_dn'), $value);
+ }
+
break;
case 'exists':
@@ -1741,16 +1750,20 @@ class Net_LDAP3
$operator = $param['type'] && in_array($param['type'], $operators) ? $param['type'] : '=';
- if (is_array($param['value'])) {
+ if (count($value) < 2) {
+ $value = array_pop($value);
+ }
+
+ if (is_array($value)) {
$val_filter = array();
- foreach ($param['value'] as $val) {
- $value = self::quote_string($val);
- $val_filter[] = "(" . $field . $operator . $prefix . $value . $suffix . ")";
+ foreach ($value as $val) {
+ $val = self::quote_string($val);
+ $val_filter[] = "(" . $field . $operator . $prefix . $val . $suffix . ")";
}
$filter .= "(|" . implode($val_filter, '') . ")";
}
else {
- $value = self::quote_string($param['value']);
+ $value = self::quote_string($value);
$filter .= "(" . $field . $operator . $prefix . $value . $suffix . ")";
}
}