Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 1x |
/**
* Checks to see if the specified group exists.
*
* @param {Object} [opts] Optional LDAP query string parameters to execute. { scope: '', filter: '', attributes: [ '', '', ... ], sizeLimit: 0, timelimit: 0 }
* @param {String} groupName The group to check to see if it exists.
* @param {Function} callback The callback to execute when completed. callback(err: {Object}, result: {Boolean})
*/
function groupExists(opts, groupName, callback) {
var self = this;
return new Promise((resolve, reject) => {
if (typeof (groupName) === 'function') {
callback = groupName;
groupName = opts;
opts = undefined;
}
log.trace('groupExists(%j,%s)', opts, groupName);
self.findGroup(opts, groupName, function (err, result) {
if (err) {
if(callback){
callback(err);
}
return reject(err);
}
log.info('"%s" %s exist.', groupName, (result != null) ? 'DOES' : 'DOES NOT');
if(callback){
callback(null, result != null);
}
return resolve(result != null);
});
});
};
module.exports = groupExists; |