function queryLdap(client, searchBase, scope, filter) {
  const opts = {
    scope,
    filter,
  };

  appLog.debug(opts, `Running LDAP search with searchBase ${searchBase}`);

  return new Promise((resolve, reject) => {
    client.search(searchBase, opts, (err, res) => {
      const results = [];
      if (err) {
        return reject(err);
      }

      res.on('searchEntry', function (entry) {
        results.push(entry.object);
      });
      res.on('error', function (err) {
        reject(err);
      });
      res.on('end', function () {
        resolve(results);
      });
    });
  });
}
Convenience wrapper to query ldap and get an array of results
If nothing found empty array is returned
@param {*} client
@param {string} searchBase
@param {string} scope - base or sub
@param {string} filter - ldap query string