Skip to content
This repository has been archived by the owner on Sep 3, 2021. It is now read-only.

PLAT-700 Limit ldap heartbeat search query scope and size #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
14 changes: 12 additions & 2 deletions lib/ldap.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ function initializeConnection () {
});

connection.heartbeat = function (callback) {
connection.search('', '(objectclass=*)', function (err, res) {
const searchOpts = {
filter: '(objectclass=person)',
scope: 'sub',
sizeLimit: 1
};
connection.search(nconf.get('LDAP_BASE'), searchOpts , function (err, res) {
if (err) {
return callback(err);
}
Expand All @@ -47,7 +52,12 @@ function initializeConnection () {
res.once('error', function(err) {
client.removeAllListeners('end');
clearTimeout(abort);
callback(err);
// if there are more than one entry matching the search, the server returns the one entry and a SizeLimitExceededError error
if (err.name === 'SizeLimitExceededError') {
callback();
} else {
callback(err);
}
}).once('end', function () {
client.removeAllListeners('error');
clearTimeout(abort);
Expand Down