clearCb( function (string $uid) use ($dispatcher): void { $dispatcher->dispatchTyped(new BeforeUserIdUnassignedEvent($uid)); \OC::$server->getUserManager()->emit('\OC\User', 'preUnassignedUserId', [$uid]); }, function (string $uid) use ($dispatcher): void { $dispatcher->dispatchTyped(new UserIdUnassignedEvent($uid)); \OC::$server->getUserManager()->emit('\OC\User', 'postUnassignedUserId', [$uid]); } ); } elseif ($subject === 'group') { $mapping = new GroupMapping(\OC::$server->getDatabaseConnection()); $result = $mapping->clear(); } if ($mapping === null || !$result) { $l = Util::getL10N('user_ldap'); throw new \Exception($l->t('Failed to clear the mappings.')); } \OC_JSON::success(); } catch (\Exception $e) { \OC_JSON::error(['message' => $e->getMessage()]); }