Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all members of AD group via LDAP in Java

I have written an application that retrieves Active Directory groups and flattens them, i.e. includes recursively members of subgroup to the top parent group. It works fine for small groups, but with larger groups I am facing a problem.

If number of members does not exceed 1500, they are listed in the member attribute. If there are more - then this attribute is empty and attribute with name member;range:0-1499 appears, containing first 1500 members.

My problem that I don't know how to get the rest of member set over 1500. We have groups with 8-12 thousand members. Do I need to run another query? On the Microsoft site I have seen C# code snippet on the similar matter, but couldn't make much sense of it, as they were showing how to specify a range, but not how to plug it into query. If someone knows how to do it in Java, I'd appreciate a tip.

like image 552
Gary Greenberg Avatar asked Sep 06 '25 05:09

Gary Greenberg


1 Answers

This will obviously give you the next ones:

String[] returnedAtts = { "member;range=1500-2999" };

You need to fetch the users chunk by chunk (1500 chunks) Just make a counter and update you search and retrieve the next ones until you have all of them.

like image 197
Thierry Salmon Avatar answered Sep 07 '25 20:09

Thierry Salmon