external ldap: show proper error message on timeout

This commit is contained in:
Girish Ramakrishnan
2024-01-23 23:27:06 +01:00
parent 5240068f2f
commit 793ee38f79
3 changed files with 8 additions and 6 deletions

View File

@@ -25,7 +25,6 @@ const assert = require('assert'),
eventlog = require('./eventlog.js'),
groups = require('./groups.js'),
ldap = require('ldapjs'),
once = require('./once.js'),
safe = require('safetydance'),
settings = require('./settings.js'),
tasks = require('./tasks.js'),
@@ -116,7 +115,10 @@ async function getClient(config, options) {
url: config.url,
tlsOptions: {
rejectUnauthorized: config.acceptSelfSignedCerts ? false : true
}
},
// https://github.com/ldapjs/node-ldapjs/issues/486
timeout: 60000,
connectTimeout: 10000
};
client = ldap.createClient(ldapConfig);
@@ -126,12 +128,9 @@ async function getClient(config, options) {
}
return await new Promise((resolve, reject) => {
reject = once(reject);
// ensure we don't just crash
client.on('error', function (error) {
client.on('error', function (error) { // don't reject, we must have gotten a bind error
debug('getClient: ExternalLdap client error:', error);
reject(new BoxError(BoxError.EXTERNAL_ERROR, error));
});
// skip bind auth if none exist or if not wanted