summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2012-11-08 23:01:28 +0100
committerArthur Schiwon <blizzz@owncloud.com>2012-11-12 17:00:23 +0100
commitd79e9a2da74849a058ccb88975db52b5ea4a961e (patch)
treeb2a52d18312773f2a606c33911e8e86ecc5cda07 /apps
parent89f2d4ba07e262a17ede70c25c245b7dfa09e817 (diff)
downloadnextcloud-server-d79e9a2da74849a058ccb88975db52b5ea4a961e.tar.gz
nextcloud-server-d79e9a2da74849a058ccb88975db52b5ea4a961e.zip
LDAP: cherrypick objectGUID handling from stable45, was part of PR 344
Diffstat (limited to 'apps')
-rw-r--r--apps/user_ldap/lib/access.php36
1 files changed, 35 insertions, 1 deletions
diff --git a/apps/user_ldap/lib/access.php b/apps/user_ldap/lib/access.php
index 9cbb21ead0e..b2244c17c0e 100644
--- a/apps/user_ldap/lib/access.php
+++ b/apps/user_ldap/lib/access.php
@@ -79,7 +79,13 @@ abstract class Access {
if(isset($result[$attr]) && $result[$attr]['count'] > 0) {
$values = array();
for($i=0;$i<$result[$attr]['count'];$i++) {
- $values[] = $this->resemblesDN($attr) ? $this->sanitizeDN($result[$attr][$i]) : $result[$attr][$i];
+ if($this->resemblesDN($attr)) {
+ $values[] = $this->sanitizeDN($result[$attr][$i]);
+ } elseif(strtolower($attr) == 'objectguid') {
+ $values[] = $this->convertObjectGUID2Str($result[$attr][$i]);
+ } else {
+ $values[] = $result[$attr][$i];
+ }
}
return $values;
}
@@ -730,6 +736,34 @@ abstract class Access {
}
/**
+ * @brief converts a binary ObjectGUID into a string representation
+ * @param $oguid the ObjectGUID in it's binary form as retrieved from AD
+ * @returns String
+ *
+ * converts a binary ObjectGUID into a string representation
+ * http://www.php.net/manual/en/function.ldap-get-values-len.php#73198
+ */
+ private function convertObjectGUID2Str($oguid) {
+ $hex_guid = bin2hex($oguid);
+ $hex_guid_to_guid_str = '';
+ for($k = 1; $k <= 4; ++$k) {
+ $hex_guid_to_guid_str .= substr($hex_guid, 8 - 2 * $k, 2);
+ }
+ $hex_guid_to_guid_str .= '-';
+ for($k = 1; $k <= 2; ++$k) {
+ $hex_guid_to_guid_str .= substr($hex_guid, 12 - 2 * $k, 2);
+ }
+ $hex_guid_to_guid_str .= '-';
+ for($k = 1; $k <= 2; ++$k) {
+ $hex_guid_to_guid_str .= substr($hex_guid, 16 - 2 * $k, 2);
+ }
+ $hex_guid_to_guid_str .= '-' . substr($hex_guid, 16, 4);
+ $hex_guid_to_guid_str .= '-' . substr($hex_guid, 20);
+
+ return strtoupper($hex_guid_to_guid_str);
+ }
+
+ /**
* @brief get a cookie for the next LDAP paged search
* @param $filter the search filter to identify the correct search
* @param $limit the limit (or 'pageSize'), to identify the correct search well