ad-promise
Advanced tools
Comparing version 1.2.0 to 1.3.0
module.exports = { | ||
chunks : null, | ||
members : 200 | ||
maxSearchesAtOnce: 3000 | ||
} |
@@ -42,8 +42,22 @@ | ||
return resolve(members) | ||
}) | ||
}); | ||
}) | ||
}, [members], self.opts.maxSearchesAtOnce || maxPromiseConfig.members, "members"); | ||
}, [members], null, "members", { | ||
Reject : { | ||
rejectBehaviour : "retry", | ||
retryAttempts : 15 | ||
}, | ||
// Timeout : { | ||
// timeoutBehaviour : "retry", | ||
// timeoutMillis : 300, | ||
// retryAttempts : 10 | ||
// }, | ||
// Reject : { | ||
// rejectBehaviour : "none" | ||
// } | ||
}); | ||
Promise.all(searchResults.map(res => {return res.promiseFunc})).then(async Members =>{ | ||
Promise.all(searchResults.map(res => {return res.result})).then(async Members =>{ | ||
Members = Members[0]; | ||
@@ -50,0 +64,0 @@ let nestedUsersArr = []; |
@@ -10,2 +10,4 @@ | ||
const log = require('./service.log'); | ||
const limitpromises = require('limitpromises'); | ||
const maxPromiseConfig = require('../../configs/config.maxPromiseGroup'); | ||
const defaultPageSize = 1000; // The maximum number of results that AD will return in a single call. Default=1000 | ||
@@ -198,18 +200,39 @@ | ||
client.search(baseDN, getLdapOpts(opts), controls, function onSearch(err, res) { | ||
if (err) { | ||
if (callback) callback(err); | ||
return; | ||
// We want to limit the total of the searches, we will use [true] as InputValues as we don't use it anyways in the function | ||
limitpromises(Input => { | ||
return new Promise((resolve, reject) => { | ||
client.search(baseDN, getLdapOpts(opts), controls, function onSearch(err, res) { | ||
if (err) { | ||
if (callback) callback(err); | ||
reject(err); | ||
return; | ||
} | ||
res.on('searchEntry', entry => { | ||
onSearchEntry(entry); | ||
resolve(); | ||
}); | ||
res.on('searchReference', ref => { | ||
onReferralChase(ref); | ||
resolve(); | ||
}); | ||
res.on('error', function (err) { | ||
onClientError(err, res); | ||
return resolve(); | ||
}); | ||
res.on('end', function (result) { | ||
isDone = true; // Flag that the primary query is complete | ||
onSearchEnd(result); | ||
return resolve(); | ||
}); | ||
}); | ||
}); | ||
}, [true], self.opts.maxSearchesAtOnce || maxPromiseConfig.maxSearchesAtOnce, "searches", { | ||
Reject : { | ||
rejectBehaviour : "retry", | ||
retryAttempts : 1 | ||
} | ||
res.on('searchEntry', onSearchEntry); | ||
res.on('searchReference', onReferralChase); | ||
res.on('error', function (err) { onClientError(err, res); }); | ||
res.on('end', function (result) { | ||
isDone = true; // Flag that the primary query is complete | ||
onSearchEnd(result); | ||
}); | ||
}); | ||
}); | ||
} | ||
module.exports = search; |
@@ -31,6 +31,26 @@ var _ = require('underscore'); | ||
let result = []; | ||
let groups = limitPromises(GroupName => { | ||
return new Promise((resolve, reject) => { | ||
self.findGroup( | ||
_.defaults( | ||
{}, _.omit(opts || {}, 'attributes'), | ||
{attributes: joinAttributes((opts || {}).attributes || defaultAttributes.group, ['member'])} | ||
), | ||
GroupName).then(group => { | ||
resolve(group); | ||
}, err => { | ||
reject(err); | ||
}); | ||
}); | ||
}, [groupName], null, "members", { | ||
Reject: { | ||
rejectBehaviour: "retry", | ||
retryAttempts : 10 | ||
} | ||
}); | ||
self.findGroup(_.defaults({}, _.omit(opts || {}, 'attributes'), { | ||
attributes: joinAttributes((opts || {}).attributes || defaultAttributes.group, ['member']) | ||
}), groupName).then(async function (group) { | ||
Promise.all(groups.map(p => {return p.result})).then(async groups => { | ||
let group = groups[0]; | ||
// Group not found | ||
@@ -84,3 +104,8 @@ if (!group) { | ||
}); | ||
}, chunks, maxPromiseConfig.chunks, "chunks"); | ||
}, chunks, maxPromiseConfig.chunks, "chunks", { | ||
Reject: { | ||
rejectBehaviour: "retry", | ||
retryAttempts: 5 | ||
} | ||
}); | ||
@@ -90,3 +115,3 @@ | ||
await Promise.all(allChunks.map(Chunk => { | ||
return Chunk.promiseFunc | ||
return Chunk.result | ||
})).then(data => { | ||
@@ -104,8 +129,4 @@ if(callback){ | ||
}); | ||
}, err => { | ||
if (callback) callback(err); | ||
return reject(err); | ||
}); | ||
}); | ||
@@ -112,0 +133,0 @@ |
{ | ||
"author": "Relief Melone (relief.melone@gmail.com)", | ||
"name": "ad-promise", | ||
"version": "1.2.0", | ||
"description": "This is a fork of the gheeres node-activedirectory. This is still a work in progress and not stable. The goal to use promises instead of the async library which is causing some problems in the current version of node-activedirectory", | ||
"version": "1.3.0", | ||
"description": "This is a fork of the gheeres node-activedirectory. It fixes some issues with timeouts with very large AD-Groups as well as returning also promises so you won't have to use callbacks", | ||
"main": "index.js", | ||
@@ -7,0 +7,0 @@ "directories": { |
@@ -72,2 +72,3 @@ AD-Promise for Node | ||
<a name="authenticate" /> | ||
### authenticate(username, password, callback) | ||
@@ -117,2 +118,3 @@ | ||
<a name="isUserMemberOf" /> | ||
### isUserMemberOf(opts, username, groupName, callback) | ||
@@ -148,2 +150,3 @@ | ||
<a name="groupExists" /> | ||
### groupExists(opts, groupName, callback) | ||
@@ -186,2 +189,3 @@ | ||
<a name="userExists" /> | ||
### userExists(opts, username, callback) | ||
@@ -224,2 +228,3 @@ | ||
<a name="getUsersForGroup" /> | ||
### getUsersForGroup(opts, groupName, callback) | ||
@@ -267,2 +272,3 @@ | ||
<a name="getGroupMembershipForUser" /> | ||
### getGroupMembershipForUser(opts, username, callback) | ||
@@ -306,2 +312,3 @@ | ||
<a name="getGroupMembershipForGroup" /> | ||
### getGroupMembershipForGroup(opts, groupName, callback) | ||
@@ -346,2 +353,3 @@ | ||
<a name="find" /> | ||
### find(opts, callback) | ||
@@ -394,2 +402,3 @@ | ||
<a name="findDeletedObjects" /> | ||
### findDeletedObjects(opts, callback) | ||
@@ -436,2 +445,3 @@ | ||
<a name="findUser" /> | ||
### findUser(opts, username, callback) | ||
@@ -473,2 +483,3 @@ | ||
<a name="findUsers" /> | ||
### findUsers(opts, callback) | ||
@@ -505,2 +516,3 @@ | ||
<a name="findGroup" /> | ||
### findGroup(opts, groupName, callback) | ||
@@ -545,2 +557,3 @@ | ||
<a name="findGroups" /> | ||
### findGroups(opts, callback) | ||
@@ -577,2 +590,3 @@ | ||
<a name="getRootDSE" /> | ||
### getRootDSE(url, attributes, callback) | ||
@@ -718,2 +732,3 @@ | ||
<a name="opts" /> | ||
### Optional Parameters / Extended Functionality | ||
@@ -769,7 +784,8 @@ | ||
<a name="authenticate" /> | ||
<a name="maxSearchesAtOnce" /> | ||
### maxSearchesAtOnce | ||
Originally node-activedirectory does not limit how many searches will be sent via LDAP parallel. This will cause problems with | ||
very large AD-Groups (10k+ users). ad-promise will limit this to 200 searches which seems to be a good trade off between performance | ||
very large AD-Groups (10k+ users). ad-promise will limit this to 5000 searches which seems to be a good trade off between performance | ||
and stability. You can however change this value if you want to. You can set the parameter like this | ||
@@ -776,0 +792,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
216701
4206
794