diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php deleted file mode 100644 index eb2ac7f81f2..00000000000 --- a/apps/user_ldap/ajax/clearMappings.php +++ /dev/null @@ -1,53 +0,0 @@ -clearCb( - function (string $uid) use ($dispatcher): void { - $dispatcher->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) use ($dispatcher): void { - $dispatcher->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(); - } - - 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()]); -} diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php deleted file mode 100644 index b9596395e99..00000000000 --- a/apps/user_ldap/ajax/getNewServerConfigPrefix.php +++ /dev/null @@ -1,33 +0,0 @@ -getNextServerConfigurationPrefix(); - -$resultData = ['configPrefix' => $nk]; - -$newConfig = new Configuration($nk, false); -if (isset($_POST['copyConfig'])) { - $originalConfig = new Configuration($_POST['copyConfig']); - $newConfig->setConfiguration($originalConfig->getConfiguration()); -} else { - $configuration = new Configuration($nk, false); - $newConfig->setConfiguration($configuration->getDefaults()); - $resultData['defaults'] = $configuration->getDefaults(); -} -$newConfig->saveConfiguration(); - -\OC_JSON::success($resultData); diff --git a/apps/user_ldap/ajax/testConfiguration.php b/apps/user_ldap/ajax/testConfiguration.php deleted file mode 100644 index b77439fa3e8..00000000000 --- a/apps/user_ldap/ajax/testConfiguration.php +++ /dev/null @@ -1,76 +0,0 @@ -getConfiguration(); - if ($conf['ldap_configuration_active'] === '0') { - //needs to be true, otherwise it will also fail with an irritating message - $conf['ldap_configuration_active'] = '1'; - } - try { - $connection->setConfiguration($conf, throw: true); - } catch (ConfigurationIssueException $e) { - $configurationError = $e->getHint(); - } - if ($configurationError === '') { - //Configuration is okay - /* - * Closing the session since it won't be used from this point on. There might be a potential - * race condition if a second request is made: either this request or the other might not - * contact the LDAP backup server the first time when it should, but there shouldn't be any - * problem with that other than the extra connection. - */ - Server::get(ISession::class)->close(); - if ($connection->bind()) { - /* - * This shiny if block is an ugly hack to find out whether anonymous - * bind is possible on AD or not. Because AD happily and constantly - * replies with success to any anonymous bind request, we need to - * fire up a broken operation. If AD does not allow anonymous bind, - * it will end up with LDAP error code 1 which is turned into an - * exception by the LDAP wrapper. We catch this. Other cases may - * pass (like e.g. expected syntax error). - */ - try { - $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', ['dn']); - } catch (\Exception $e) { - if ($e->getCode() === 1) { - \OC_JSON::error(['message' => $l->t('Invalid configuration: Anonymous binding is not allowed.')]); - exit; - } - } - \OC_JSON::success(['message' - => $l->t('Valid configuration, connection established!')]); - } else { - \OC_JSON::error(['message' - => $l->t('Valid configuration, but binding failed. Please check the server settings and credentials.')]); - } - } else { - \OC_JSON::error(['message' - => $l->t('Invalid configuration: %s', $configurationError)]); - } -} catch (\Exception $e) { - \OC_JSON::error(['message' => $e->getMessage()]); -} diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php deleted file mode 100644 index 056299e1bff..00000000000 --- a/apps/user_ldap/ajax/wizard.php +++ /dev/null @@ -1,120 +0,0 @@ - $l->t('No action specified')]); -} -$action = (string)$_POST['action']; - -if (!isset($_POST['ldap_serverconfig_chooser'])) { - \OC_JSON::error(['message' => $l->t('No configuration specified')]); -} -$prefix = (string)$_POST['ldap_serverconfig_chooser']; - -$ldapWrapper = new LDAP(); -$configuration = new Configuration($prefix); - -$con = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix, null); -$con->setConfiguration($configuration->getConfiguration()); -$con->ldapConfigurationActive = (string)true; -$con->setIgnoreValidation(true); - -$factory = Server::get(AccessFactory::class); -$access = $factory->get($con); - -$wizard = new Wizard($configuration, $ldapWrapper, $access); - -switch ($action) { - 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->$action(); - if ($result !== false) { - \OC_JSON::success($result->getResultArray()); - exit; - } - } catch (\Exception $e) { - \OC_JSON::error(['message' => $e->getMessage(), 'code' => $e->getCode()]); - exit; - } - \OC_JSON::error(); - exit; - break; - - case 'testLoginName': { - try { - $loginName = $_POST['ldap_test_loginname']; - $result = $wizard->$action($loginName); - if ($result !== false) { - \OC_JSON::success($result->getResultArray()); - exit; - } - } catch (\Exception $e) { - \OC_JSON::error(['message' => $e->getMessage()]); - exit; - } - \OC_JSON::error(); - exit; - break; - } - - case 'save': - $key = $_POST['cfgkey'] ?? false; - $val = $_POST['cfgval'] ?? null; - if ($key === false || is_null($val)) { - \OC_JSON::error(['message' => $l->t('No data specified')]); - exit; - } - if (is_array($key)) { - \OC_JSON::error(['message' => $l->t('Invalid data specified')]); - exit; - } - $cfg = [$key => $val]; - $setParameters = []; - $configuration->setConfiguration($cfg, $setParameters); - if (!in_array($key, $setParameters)) { - \OC_JSON::error(['message' => $l->t('Could not set configuration %1$s to %2$s', [$key, $setParameters[0]])]); - exit; - } - $configuration->saveConfiguration(); - //clear the cache on save - $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); - $connection->clearCache(); - \OC_JSON::success(); - break; - default: - \OC_JSON::error(['message' => $l->t('Action does not exist')]); - break; -} diff --git a/apps/user_ldap/appinfo/routes.php b/apps/user_ldap/appinfo/routes.php index 11c0d2ca6f5..ca4b488cd9b 100644 --- a/apps/user_ldap/appinfo/routes.php +++ b/apps/user_ldap/appinfo/routes.php @@ -7,14 +7,6 @@ declare(strict_types=1); * SPDX-FileCopyrightText: 2016 ownCloud, Inc. * SPDX-License-Identifier: AGPL-3.0-only */ -$this->create('user_ldap_ajax_clearMappings', 'apps/user_ldap/ajax/clearMappings.php') - ->actionInclude('user_ldap/ajax/clearMappings.php'); -$this->create('user_ldap_ajax_getNewServerConfigPrefix', 'apps/user_ldap/ajax/getNewServerConfigPrefix.php') - ->actionInclude('user_ldap/ajax/getNewServerConfigPrefix.php'); -$this->create('user_ldap_ajax_testConfiguration', 'apps/user_ldap/ajax/testConfiguration.php') - ->actionInclude('user_ldap/ajax/testConfiguration.php'); -$this->create('user_ldap_ajax_wizard', 'apps/user_ldap/ajax/wizard.php') - ->actionInclude('user_ldap/ajax/wizard.php'); return [ 'routes' => [ diff --git a/apps/user_ldap/lib/Wizard.php b/apps/user_ldap/lib/Wizard.php index 15a9f9cb212..fa77fea8fa2 100644 --- a/apps/user_ldap/lib/Wizard.php +++ b/apps/user_ldap/lib/Wizard.php @@ -199,7 +199,7 @@ class Wizard extends LDAPUtility { $count = (int)$this->countUsersWithAttribute($attr, true); if ($count > 0) { //no change, but we sent it back to make sure the user interface - //is still correct, even if the ajax call was cancelled meanwhile + //is still correct, even if the call was cancelled meanwhile $this->result->addChange('ldap_display_name', $attr); return $this->result; }