Skip to content

Commit b72216f

Browse files
committed
Merge pull request #86 from tcort/findandbind-callback-with-data
findandbind: pass found entry to callback
2 parents c9f727b + 70896ac commit b72216f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,14 @@ LDAP.prototype.findandbind = function(opt, fn) {
193193
if (this.auth_connection === undefined) {
194194
this.auth_connection = new LDAP(this.options, function newAuthConnection(err) {
195195
if (err) return fn(err);
196-
return this.authbind(data[0].dn, opt.password, fn);
196+
return this.authbind(data[0].dn, opt.password, function authbindResult(err) {
197+
fn(err, data[0]);
198+
});
197199
}.bind(this));
198200
} else {
199-
this.authbind(data[0].dn, opt.password, fn);
201+
this.authbind(data[0].dn, opt.password, function authbindResult(err) {
202+
fn(err, data[0]);
203+
});
200204
}
201205
return undefined;
202206
}.bind(this));

test/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ describe('LDAP', function() {
8989
password: 'foobarbaz'
9090
}, function(err, data) {
9191
assert.ifError(err);
92+
assert.equal(data.cn, 'Charlie');
9293
done();
9394
});
9495
});
@@ -100,6 +101,7 @@ describe('LDAP', function() {
100101
password: 'foobarbaz'
101102
}, function(err, data) {
102103
assert.ifError(err);
104+
assert.equal(data.cn, 'Charlie');
103105
done();
104106
});
105107
});

0 commit comments

Comments
 (0)