passbolt/passbolt_api · error · BadRequestException

Could not save the settings.

Error message

Could not save the settings. {0}

What it means

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.

Solutions

  1. Check the interpolated message and the chained exception in server logs for the root cause.
  2. Verify LDAP server reachability with ldapsearch/ldapwhoami from the passbolt host.
  3. Confirm bind DN/password and base DN are correct.
  4. If using LDAPS, ensure the CA certificate is trusted by the container/host.
  5. Ensure the php-ldap extension is installed and enabled (`php -m | grep ldap`).

Example fix

// before
"ldap.username": "cn=admin,dc=example,dc=com" (wrong password)
// 400 Could not save the settings. Invalid credentials
// after
# verify credentials outside passbolt first
ldapwhoami -H ldaps://ldap.example.com:636 -D 'cn=admin,dc=example,dc=com' -W
# then submit corrected settings
Defensive patterns

Strategy: try-catch

Try / catch

try {
    await api.post('/directorysync/settings.json', payload);
} catch (e) {
    if (e.response?.status === 400 && String(e.response.data?.message || '').startsWith('Could not save the settings.')) {
        const cause = e.response.data.message.replace('Could not save the settings. ', '');
        // cause is the LDAP execution error: fix credentials/connectivity before retry
    }
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of passbolt/passbolt_api@31c1bbc10f (2026-09-17). Data as JSON: /api/errors/255b29f134724076. Report an issue: GitHub.

Appendix: source

Thrown at plugins/PassboltEe/DirectorySync/src/Controller/DirectorySettingsController.php:87

     *
     * @return void
     */
    public function update()
    {
        if (!$this->User->isAdmin()) {
            throw new ForbiddenException(__('You are not authorized to access that location.'));
        }

        $data = $this->request->getData();
        $form = new LdapConfigurationForm();
        if (!$form->validate($data)) {
            $errors = $form->getErrors();
            throw new CustomValidationException(__('Could not validate settings.'), $errors);
        }
        try {
            $form->execute($data);
        } catch (Exception $e) {
            throw new BadRequestException(
                __('Could not save the settings. {0}', $e->getMessage()),
                null,
                $e
            );
        }

        $uac = $this->User->getAccessControl();
        $settings = LdapConfigurationForm::formatFormDataToOrgSettings($data);
        $directoryOrgSettings = new DirectoryOrgSettings($settings);
        $directoryOrgSettings->save($uac);

        $this->success(__('The operation was successful.'));
    }

    /**
     * Test provided settings without saving them, and return directory results.
     *
     * @return void

View on GitHub (pinned to 31c1bbc10f)