@@ -345,7 +345,7 @@ public function extractRangeData($result, $attribute) {
345345 }
346346 return [];
347347 }
348-
348+
349349 /**
350350 * Set password for an LDAP user identified by a DN
351351 *
@@ -652,6 +652,8 @@ public function mapAndAnnounceIfApplicable(
652652 if ($ this ->ncUserManager instanceof PublicEmitter && $ isUser ) {
653653 $ this ->cacheUserExists ($ name );
654654 $ this ->ncUserManager ->emit ('\OC\User ' , 'assignedUserId ' , [$ name ]);
655+ } elseif (!$ isUser ) {
656+ $ this ->cacheGroupExists ($ name );
655657 }
656658 return true ;
657659 }
@@ -761,6 +763,13 @@ public function cacheUserExists($ocName) {
761763 $ this ->connection ->writeToCache ('userExists ' .$ ocName , true );
762764 }
763765
766+ /**
767+ * caches a group as existing
768+ */
769+ public function cacheGroupExists (string $ gid ): void {
770+ $ this ->connection ->writeToCache ('groupExists ' .$ gid , true );
771+ }
772+
764773 /**
765774 * caches the user display name
766775 *
@@ -958,7 +967,15 @@ public function batchApplyUserAttributes(array $ldapRecords){
958967 * @return array
959968 */
960969 public function fetchListOfGroups ($ filter , $ attr , $ limit = null , $ offset = null ) {
961- return $ this ->fetchList ($ this ->searchGroups ($ filter , $ attr , $ limit , $ offset ), $ this ->manyAttributes ($ attr ));
970+ $ groupRecords = $ this ->searchGroups ($ filter , $ attr , $ limit , $ offset );
971+ array_walk ($ groupRecords , function ($ record ) {
972+ $ newlyMapped = false ;
973+ $ gid = $ this ->dn2ocname ($ record ['dn ' ][0 ], null , false , $ newlyMapped , $ record );
974+ if (!$ newlyMapped && is_string ($ gid )) {
975+ $ this ->cacheGroupExists ($ gid );
976+ }
977+ });
978+ return $ this ->fetchList ($ groupRecords , $ this ->manyAttributes ($ attr ));
962979 }
963980
964981 /**
0 commit comments