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

Get all Users from AD #177

Open tdungnguyen opened 7 years ago

tdungnguyen commented 7 years ago

Hi George,

I am implementing an API to get the full list of all active users from AD. It's still new for me to program, so my logic in this question may be stupid (forgive me ahead).

For started, I tried function findUsers with a simple query as "cn=*", the result returned with 1000 items according to the configuration from AD server. I already tried with paging.pageSize = 2000 but it still returned 1000.

So I tried with another approach: first I get the list of all groups, and for-loop those groups to get the users belong to the group, sum recursively the group users and distinct the final result (just to make sure). I have 2 main functions: getAllGroups() and getUsersForGroups(groupName), and a callback recursive handler to store partial results. Is this a fine implementation??

Luckily, my AD server only has a number which is smaller than 1000, so I get the results which is larger than 1000.

Still, there is one problem that I am facing: The final result of all users was returned differently on every trigger.

So, could you gimme some advice for this one?

Harekam commented 7 years ago

Hi, Did you find any solution for this?

tdungnguyen commented 7 years ago

@Harekam yes I did. I passed this module and implemented with node-ldapjs. Its document is really well, and you can apply Paging query with exact result