getGroupManager()->search($pattern, $limit, $offset) as $group) { $groups[$group->getGID()] = $group->getDisplayName(); } $users = []; foreach (\OC::$server->getUserManager()->searchDisplayName($pattern, $limit, $offset) as $user) { $users[$user->getUID()] = $user->getDisplayName(); } $results = ['groups' => $groups, 'users' => $users]; \OC_JSON::success($results);