]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: implement UUID and internal username override
authorArthur Schiwon <blizzz@owncloud.com>
Wed, 8 May 2013 12:56:52 +0000 (14:56 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Wed, 8 May 2013 12:56:52 +0000 (14:56 +0200)
apps/user_ldap/lib/access.php

index 234e91f792fdad998aa39851e43bebbb91c67b9f..8c372766c006dce65e2554a5c03a46494ce1dc04 100644 (file)
@@ -317,7 +317,19 @@ abstract class Access {
                        }
                        $ldapname = $ldapname[0];
                }
-               $intname = $isUser ? $this->sanitizeUsername($uuid) : $ldapname;
+
+               if($isUser) {
+                       $usernameAttribute = $this->connection->ldapExpertUsernameAttr;
+                       if(!emptY($usernameAttribute)) {
+                               $username = $this->readAttribute($dn, $usernameAttribute);
+                               $username = $username[0];
+                       } else {
+                               $username = $uuid;
+                       }
+                       $intname = $this->sanitizeUsername($username);
+               } else {
+                       $intname = $ldapname;
+               }
 
                //a new user/group! Add it only if it doesn't conflict with other backend's users or existing groups
                //disabling Cache is required to avoid that the new user is cached as not-existing in fooExists check
@@ -897,6 +909,12 @@ abstract class Access {
                        return true;
                }
 
+               $fixedAttribute = $this->connection->ldapExpertUUIDAttr;
+               if(!empty($fixedAttribute)) {
+                       $this->connection->ldapUuidAttribute = $fixedAttribute;
+                       return true;
+               }
+
                //for now, supported (known) attributes are entryUUID, nsuniqueid, objectGUID
                $testAttributes = array('entryuuid', 'nsuniqueid', 'objectguid', 'guid');