aboutsummaryrefslogtreecommitdiffstats
path: root/apps/user_ldap
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-06-25 13:16:35 +0200
committerArthur Schiwon <blizzz@owncloud.com>2012-06-25 13:22:00 +0200
commitd64a7716f1a32cda698cb26597d074de8b9ab245 (patch)
treede3350e7c6d3b35ec33dff8d56bb2194af8b0e7e /apps/user_ldap
parenta09a01a49fbbb7e821c0e9d259586930d51a87d5 (diff)
downloadnextcloud-server-d64a7716f1a32cda698cb26597d074de8b9ab245.tar.gz
nextcloud-server-d64a7716f1a32cda698cb26597d074de8b9ab245.zip
LDAP: always sanitize DN and DN-containing attributes
Diffstat (limited to 'apps/user_ldap')
-rw-r--r--apps/user_ldap/lib_ldap.php15
1 files changed, 12 insertions, 3 deletions
diff --git a/apps/user_ldap/lib_ldap.php b/apps/user_ldap/lib_ldap.php
index c88b18b10d3..2940e1d8252 100644
--- a/apps/user_ldap/lib_ldap.php
+++ b/apps/user_ldap/lib_ldap.php
@@ -425,7 +425,7 @@ class OC_LDAP {
if(isset($result[$attr]) && $result[$attr]['count'] > 0){
$values = array();
for($i=0;$i<$result[$attr]['count'];$i++) {
- $values[] = $result[$attr][$i];
+ $values[] = self::resemblesDN($attr) ? self::sanitizeDN($result[$attr][$i]) : $result[$attr][$i];
}
return $values;
}
@@ -508,7 +508,7 @@ class OC_LDAP {
$key = strtolower($key);
if(isset($item[$key])) {
if($key != 'dn'){
- $selection[$i][$key] = $item[$key][0];
+ $selection[$i][$key] = self::resemblesDN($key) ? self::sanitizeDN($item[$key][0]) : $item[$key][0];
} else {
$selection[$i][$key] = self::sanitizeDN($item[$key]);
}
@@ -521,7 +521,7 @@ class OC_LDAP {
$key = strtolower($attr[0]);
if(isset($item[$key])) {
- if($key == 'dn') {
+ if(self::resemblesDN($key)) {
$selection[] = self::sanitizeDN($item[$key]);
} else {
$selection[] = $item[$key];
@@ -536,6 +536,15 @@ class OC_LDAP {
return $findings;
}
+ static private function resemblesDN($attr) {
+ $resemblingAttributes = array(
+ 'dn',
+ 'uniquemember',
+ 'member'
+ );
+ return in_array($attr, $resemblingAttributes);
+ }
+
static private function sanitizeDN($dn) {
//OID sometimes gives back DNs with whitespace after the comma a la "uid=foo, cn=bar, dn=..." We need to tackle this!
$dn = preg_replace('/([^\\\]),(\s+)/','\1,',$dn);