salix/modules/account/back/util/ldapjs-extra.js

31 lines
614 B
JavaScript
Raw Normal View History

2020-09-21 11:24:43 +00:00
const ldap = require('ldapjs');
const promisifyObject = require('./promisify').promisifyObject;
module.exports = {
createClient,
Change: ldap.Change
};
/**
* Creates a promisified version of LDAP client.
*
* @param {Object} opts Client options
* @return {Client} The promisified LDAP client
*/
function createClient(opts) {
let client = ldap.createClient(opts);
promisifyObject(client, [
'bind',
'add',
'compare',
'del',
'exop',
'modify',
'modifyDN',
'search',
'starttls',
'unbind'
]);
return client;
}