@@ -84,16 +84,19 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b
8484 $ shareeEnumerationFullMatch = $ this ->appConfig ->getValueString ('core ' , 'shareapi_restrict_user_enumeration_full_match ' , 'yes ' ) === 'yes ' ;
8585 if ($ shareeEnumerationFullMatch && $ search !== '' ) {
8686 $ shareeEnumerationFullMatchUserId = $ this ->appConfig ->getValueString ('core ' , 'shareapi_restrict_user_enumeration_full_match_user_id ' , 'yes ' ) === 'yes ' ;
87+ $ shareeEnumerationFullMatchDisplayName = $ this ->appConfig ->getValueString ('core ' , 'shareapi_restrict_user_enumeration_full_match_displayname ' , 'yes ' ) === 'yes ' ;
8788 $ shareeEnumerationFullMatchEmail = $ this ->appConfig ->getValueString ('core ' , 'shareapi_restrict_user_enumeration_full_match_email ' , 'yes ' ) === 'yes ' ;
8889 $ shareeEnumerationFullMatchIgnoreSecondDisplayName = $ this ->appConfig ->getValueString ('core ' , 'shareapi_restrict_user_enumeration_full_match_ignore_second_dn ' , 'no ' ) === 'yes ' ;
8990
9091 $ lowerSearch = mb_strtolower ($ search );
9192
92- // Re-use the results from earlier if possible
93- $ usersByDisplayName ??= $ this ->userManager ->searchDisplayName ($ search , $ limit , $ offset );
94- foreach ($ usersByDisplayName as $ user ) {
95- if ($ user ->isEnabled () && (mb_strtolower ($ user ->getDisplayName ()) === $ lowerSearch || ($ shareeEnumerationFullMatchIgnoreSecondDisplayName && trim (mb_strtolower (preg_replace ('/ \(.*\)$/ ' , '' , $ user ->getDisplayName ()))) === $ lowerSearch ))) {
96- $ users [$ user ->getUID ()] = ['exact ' , $ user ];
93+ if ($ shareeEnumerationFullMatchDisplayName ) {
94+ // Re-use the results from earlier if possible
95+ $ usersByDisplayName ??= $ this ->userManager ->searchDisplayName ($ search , $ limit , $ offset );
96+ foreach ($ usersByDisplayName as $ user ) {
97+ if ($ user ->isEnabled () && (mb_strtolower ($ user ->getDisplayName ()) === $ lowerSearch || ($ shareeEnumerationFullMatchIgnoreSecondDisplayName && trim (mb_strtolower (preg_replace ('/ \(.*\)$/ ' , '' , $ user ->getDisplayName ()))) === $ lowerSearch ))) {
98+ $ users [$ user ->getUID ()] = ['exact ' , $ user ];
99+ }
97100 }
98101 }
99102
0 commit comments