gheeres / node-activedirectory

ActiveDirectory is an Node.js ldapjs client for authN (authentication) and authZ (authorization) for Microsoft Active Directory with range retrieval support for large Active Directory installations.
MIT License
534 stars 146 forks source link

sizeLimit don't working #124

Open Damassk opened 8 years ago

Damassk commented 8 years ago

On my ActiveDirectory server set MaxPageLimit to 2500 and command 'ldapsearch' confirmed this value. I have 2433 user in AD. But when I'm trying to get all users from AD, the most get only 1,000. I'm tried use paging, sizeLimit and pageSize param, but I have no changes. My code:

var ad = new ActiveDirectory(config);
        var query = {
            filter: '(&(!(sAMAccountName=*_envtest))(objectClass=User))',
            //paging: true,
            //sizeLimit: 2500,
            paging: {
                pageSize: 2500
            }
        };
        ad.findUsers(query, false, function(err, users) {
        // TODO
}
Damassk commented 8 years ago

I fix this problem add sizeLimit params to lib/activedirectory.js My fix:

var sizeLimit = opts.sizeLimit || defaultPageSize;
  // Add paging results control by default if not already added.
  if (!_.any(controls, function(control) { return(control instanceof ldap.PagedResultsControl); })) {
    log.debug('Adding PagedResultControl to search (%s) with filter "%s" for %j',
              baseDN, truncateLogOutput(opts.filter), _.any(opts.attributes) ? opts.attributes : '[*]');
    controls.push(new ldap.PagedResultsControl({ value: { size: sizeLimit } }));
  }
jsumners commented 8 years ago

@Damassk would you be up for testing this against my es2015 branch? I'd like to know if the bug still persists as you understand it.

https://github.com/jsumners/node-activedirectory/tree/es2015

fjuarez67 commented 8 years ago

Is this bug fixed? I am seeing the same issue. Only getting 1000 records when the AD server is set to 5000 limit..

gheeres commented 8 years ago

Please apply the patch / change that Damassk specified and get back to us on your results. If confirmed, I can merge those changes and publish and updated version.

fjuarez67 commented 8 years ago

Tried both: 1) set the defaulPageSize to 5000. That worked.. 2) applied the patch from Damassk ( code above) that also worked.

Regards.

oceddi commented 8 years ago

I'm also seeing this bug.