{"record":{"id":"255b29f134724076","repo":"passbolt/passbolt_api","slug":"could-not-save-the-settings-0","errorCode":null,"errorMessage":"Could not save the settings. {0}","messagePattern":"Could not save the settings\\. (.+?)","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"plugins/PassboltEe/DirectorySync/src/Controller/DirectorySettingsController.php","lineNumber":87,"sourceCode":"     *\n     * @return void\n     */\n    public function update()\n    {\n        if (!$this->User->isAdmin()) {\n            throw new ForbiddenException(__('You are not authorized to access that location.'));\n        }\n\n        $data = $this->request->getData();\n        $form = new LdapConfigurationForm();\n        if (!$form->validate($data)) {\n            $errors = $form->getErrors();\n            throw new CustomValidationException(__('Could not validate settings.'), $errors);\n        }\n        try {\n            $form->execute($data);\n        } catch (Exception $e) {\n            throw new BadRequestException(\n                __('Could not save the settings. {0}', $e->getMessage()),\n                null,\n                $e\n            );\n        }\n\n        $uac = $this->User->getAccessControl();\n        $settings = LdapConfigurationForm::formatFormDataToOrgSettings($data);\n        $directoryOrgSettings = new DirectoryOrgSettings($settings);\n        $directoryOrgSettings->save($uac);\n\n        $this->success(__('The operation was successful.'));\n    }\n\n    /**\n     * Test provided settings without saving them, and return directory results.\n     *\n     * @return void","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/passbolt/passbolt_api/blob/31c1bbc10f32808a607fa9bd81891e898779c0bc/plugins/PassboltEe/DirectorySync/src/Controller/DirectorySettingsController.php#L69-L105","documentation":"Thrown when LdapConfigurationForm::execute() throws during POST /directorysync/settings — validation passed but execution (e.g. testing the configuration against the LDAP server) failed. The original exception message is interpolated into '{0}' and attached as the previous exception, returned as HTTP 400.","triggerScenarios":"POST /directorysync/settings where the payload validates but $form->execute($data) fails — e.g. LDAP bind/connect test fails during execution, or an unexpected error occurs while processing the configuration.","commonSituations":"Wrong bind credentials or DN; LDAP server unreachable from the passbolt server (firewall, DNS); TLS/certificate issues (self-signed cert without proper CA); PHP LDAP extension missing on the host; typo'd base DN.","solutions":["Check the interpolated message and the chained exception in server logs for the root cause.","Verify LDAP server reachability with ldapsearch/ldapwhoami from the passbolt host.","Confirm bind DN/password and base DN are correct.","If using LDAPS, ensure the CA certificate is trusted by the container/host.","Ensure the php-ldap extension is installed and enabled (`php -m | grep ldap`)."],"exampleFix":"// before\n\"ldap.username\": \"cn=admin,dc=example,dc=com\" (wrong password)\n// 400 Could not save the settings. Invalid credentials\n// after\n# verify credentials outside passbolt first\nldapwhoami -H ldaps://ldap.example.com:636 -D 'cn=admin,dc=example,dc=com' -W\n# then submit corrected settings","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    await api.post('/directorysync/settings.json', payload);\n} catch (e) {\n    if (e.response?.status === 400 && String(e.response.data?.message || '').startsWith('Could not save the settings.')) {\n        const cause = e.response.data.message.replace('Could not save the settings. ', '');\n        // cause is the LDAP execution error: fix credentials/connectivity before retry\n    }\n    throw e;\n}","preventionTips":["Test LDAP reachability and bind with ldapsearch/ldapwhoami from the passbolt host before saving settings.","Ensure php-ldap is installed on the server/container image.","Pre-trust your LDAPS CA certificates.","Use /directorysync/test to execute settings without saving, iterating until it passes."],"tags":["ldap","execution-failed","http-400","configuration","connection"],"backgroundTag":"ldap-bind-failed","analyzedSha":"31c1bbc10f32808a607fa9bd81891e898779c0bc","analyzedAt":"2026-09-17T00:04:38.960Z","contentChangedAt":"2026-09-17T00:04:38.960Z","schemaVersion":2},"datasetVersion":"2026-09-21T09:17:21.228Z"}