Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions shell/imports/server/accounts/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ LDAP.prototype.ldapCheck = function (db, options) {
}, errorFunc);
}

client.on("error", errorFunc);

let username = options.username;
let domain = _this.options.defaultDomain;

Expand All @@ -111,22 +109,25 @@ LDAP.prototype.ldapCheck = function (db, options) {

if (_this.options.searchBindDn) {
let ldapBindFut = new Future();
client.bind(_this.options.searchBindDn, _this.options.searchBindPassword,
function (err) {
if (err) {
ldapBindFut.throw(err);
} else {
ldapBindFut.return();
}
let searchBindErrorFunc = function (err) {
if (err) {
ldapBindFut.throw(err);
} else {
ldapBindFut.return();
}
);
};

client.on("error", searchBindErrorFunc);
client.bind(_this.options.searchBindDn, _this.options.searchBindPassword, searchBindErrorFunc);

try {
ldapBindFut.wait();
} catch (err) {
return { error: err };
}
}

client.on("error", errorFunc);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intended that we may end up registering multiple on-error handlers? What is the effect of running both? You moved this line down here, so I guess ordering is important? Might be worth a comment explaining that this is expected, otherwise it looks like it could be a mistake.

// initialize result
let retObject = {
username: username,
Expand Down