Skip to content

Commit

Permalink
Fix #1491 via code from @miscs
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigok committed Jan 5, 2016
1 parent a295da4 commit 2541885
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/rocketchat-ldap/ldap_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ LDAP.prototype.ldapCheck = function(options) {
error: err
});
}
var entryCount = 0;
var dn = self.options.dn;
res.on('searchEntry', function(entry) {
entryCount++;
dn = entry.object.dn;
});
res.on('error', function(err) {
Expand All @@ -173,7 +175,15 @@ LDAP.prototype.ldapCheck = function(options) {
});
});
res.on('end', function(result) {
bind(dn);
if (entryCount === 1) {
bind(dn);
} else {
console.log('LDAP: Search returned', entryCount, 'record(s)');
var err = new Error('User not Found');
ldapAsyncFut.return({
error: err
});
}
});
});
} catch (e) {
Expand Down

0 comments on commit 2541885

Please sign in to comment.