|list>,options?:array>}, array{}> * @throws OCSException * * 200: Wizard action result */ #[AuthorizedAdminSetting(settings: Admin::class)] #[ApiRoute(verb: 'POST', url: '/api/v1/wizard/{configID}/{wizardAction}')] public function action( string $configID, string $wizardAction, ?string $loginName = null, ) { try { $wizard = $this->wizardFactory->get($configID); switch ($wizardAction) { case 'guessPortAndTLS': case 'guessBaseDN': case 'detectEmailAttribute': case 'detectUserDisplayNameAttribute': case 'determineGroupMemberAssoc': case 'determineUserObjectClasses': case 'determineGroupObjectClasses': case 'determineGroupsForUsers': case 'determineGroupsForGroups': case 'determineAttributes': case 'getUserListFilter': case 'getUserLoginFilter': case 'getGroupFilter': case 'countUsers': case 'countGroups': case 'countInBaseDN': try { $result = $wizard->$wizardAction(); if ($result !== false) { return new DataResponse($result->getResultArray()); } } catch (\Exception $e) { throw new OCSException($e->getMessage()); } throw new OCSException(); case 'testLoginName': try { if ($loginName === null || $loginName === '') { throw new OCSException('No login name passed'); } $result = $wizard->$wizardAction($loginName); if ($result !== false) { return new DataResponse($result->getResultArray()); } } catch (\Exception $e) { throw new OCSException($e->getMessage()); } throw new OCSException(); default: throw new OCSException('Action ' . $wizardAction . 'does not exist'); break; } } catch (OCSException $e) { throw $e; } catch (\Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new OCSException('An issue occurred.'); } } /** * Clear user or group mappings * * @param 'user'|'group' $subject Whether to clear group or user mappings * @return DataResponse, array{}> * @throws OCSException * * 200: Clearing was done successfuly */ #[AuthorizedAdminSetting(settings: Admin::class)] #[ApiRoute(verb: 'POST', url: '/api/v1/wizard/clearMappings')] public function clearMappings( string $subject, ) { $mapping = null; try { if ($subject === 'user') { $mapping = Server::get(UserMapping::class); $result = $mapping->clearCb( function (string $uid): void { $this->eventDispatcher->dispatchTyped(new BeforeUserIdUnassignedEvent($uid)); /** @psalm-suppress UndefinedInterfaceMethod For now we have to emit, will be removed when all hooks are removed */ Server::get(IUserManager::class)->emit('\OC\User', 'preUnassignedUserId', [$uid]); }, function (string $uid): void { $this->eventDispatcher->dispatchTyped(new UserIdUnassignedEvent($uid)); /** @psalm-suppress UndefinedInterfaceMethod For now we have to emit, will be removed when all hooks are removed */ Server::get(IUserManager::class)->emit('\OC\User', 'postUnassignedUserId', [$uid]); } ); } elseif ($subject === 'group') { $mapping = Server::get(GroupMapping::class); $result = $mapping->clear(); } else { throw new OCSException('Unsupported subject ' . $subject); } if (!$result) { throw new OCSException($this->l->t('Failed to clear the mappings.')); } return new DataResponse(); } catch (\Exception $e) { $this->logger->error($e->getMessage(), ['exception' => $e]); throw new OCSException('An issue occurred.'); } } }