]> source.dussan.org Git - nextcloud-server.git/commitdiff
LDAP: only map users within the User Base Tree
authorArthur Schiwon <blizzz@owncloud.com>
Mon, 18 Jun 2012 23:15:58 +0000 (01:15 +0200)
committerArthur Schiwon <blizzz@owncloud.com>
Mon, 18 Jun 2012 23:15:58 +0000 (01:15 +0200)
apps/user_ldap/group_ldap.php
apps/user_ldap/lib_ldap.php

index 78bc5b46566e9d7ce7ed1b31e4770207d0d1bc06..a3117b5a41e5a7711c8c0a6c32a9e2f26a955568 100644 (file)
@@ -166,7 +166,9 @@ class OC_GROUP_LDAP extends OC_Group_Backend {
                                $result[] = OC_LDAP::dn2username($ldap_users[0]);
                                continue;
                        } else {
-                               $result[] = OC_LDAP::dn2username($member);
+                               if($ocname = OC_LDAP::dn2username($member)){
+                                       $result[] = $ocname;
+                               }
                        }
                }
                if(!$isMemberUid) {
index 45be86aff817677c10a38c06f2531f508801135a..4adb70cfa0ae0ed3a16ae628b1e0a4d0dabd51dd 100644 (file)
@@ -166,11 +166,14 @@ class OC_LDAP {
         * @brief returns the internal ownCloud name for the given LDAP DN of the group
         * @param $dn the dn of the group object
         * @param $ldapname optional, the display name of the object
-        * @returns string with with the name to use in ownCloud
+        * @returns string with with the name to use in ownCloud, false on DN outside of search DN
         *
         * returns the internal ownCloud name for the given LDAP DN of the group
         */
        static public function dn2groupname($dn, $ldapname = null) {
+               if(strrpos($dn, self::ldapBaseGroups) !== (strlen($dn)-strlen(self::ldapBaseGroups)-1)) {
+                       return false;
+               }
                return self::dn2ocname($dn, $ldapname, false);
        }
 
@@ -180,9 +183,12 @@ class OC_LDAP {
         * @param $ldapname optional, the display name of the object
         * @returns string with with the name to use in ownCloud
         *
-        * returns the internal ownCloud name for the given LDAP DN of the user
+        * returns the internal ownCloud name for the given LDAP DN of the user, false on DN outside of search DN
         */
        static public function dn2username($dn, $ldapname = null) {
+               if(strrpos($dn, self::ldapBaseUsers) !== (strlen($dn)-strlen(self::ldapBaseUsers)-1)) {
+                       return false;
+               }
                return self::dn2ocname($dn, $ldapname, true);
        }