Merge pull request #405 from pbatey/master

destroy socket if auto-bind fails
This commit is contained in:
James Sumners 2019-08-26 07:52:22 -04:00 committed by GitHub
commit ac55fba157
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -348,6 +348,9 @@ function Client(options) {
this.on('setup', function (clt, cb) {
clt.bind(options.bindDN, options.bindCredentials, function (err) {
if (err) {
if (self._socket) {
self._socket.destroy()
}
self.emit('error', err);
}
cb(err);

View File

@ -334,6 +334,7 @@ test('auto-bind bad credentials', function (t) {
});
clt.once('error', function (err) {
t.equal(err.code, ldap.LDAP_INVALID_CREDENTIALS);
t.ok(clt._socket.destroyed, 'expect socket to be destroyed');
clt.destroy();
t.end();
});