diff --git a/src/externalldap.js b/src/externalldap.js index 7ce4e1f3d..20e2e9447 100644 --- a/src/externalldap.js +++ b/src/externalldap.js @@ -66,6 +66,8 @@ function testConfig(config, callback) { assert.strictEqual(typeof config, 'object'); assert.strictEqual(typeof callback, 'function'); + if (!config.enabled) return callback(); + if (!config.url) return callback(new ExternalLdapError(ExternalLdapError.BAD_FIELD, 'url must not be empty')); if (!config.baseDn) return callback(new ExternalLdapError(ExternalLdapError.BAD_FIELD, 'basedn must not be empty')); if (!config.filter) return callback(new ExternalLdapError(ExternalLdapError.BAD_FIELD, 'filter must not be empty')); diff --git a/src/routes/settings.js b/src/routes/settings.js index abd06df4e..f3eeb64f6 100644 --- a/src/routes/settings.js +++ b/src/routes/settings.js @@ -207,6 +207,7 @@ function getExternalLdapConfig(req, res, next) { function setExternalLdapConfig(req, res, next) { assert.strictEqual(typeof req.body, 'object'); + if (typeof req.body.enabled !== 'boolean') return next(new HttpError(400, 'enabled must be a boolean')); if (typeof req.body.url !== 'string' || req.body.url === '') return next(new HttpError(400, 'url must be a non empty string')); if (typeof req.body.baseDn !== 'string' || req.body.baseDn === '') return next(new HttpError(400, 'baseDn must be a non empty string')); if (typeof req.body.filter !== 'string' || req.body.filter === '') return next(new HttpError(400, 'filter must be a non empty string'));