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

31 lines
614 B
JavaScript

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;
}