Search code examples
javaactive-directoryldapactivedirectorymembership

How can I change this filter from a specific AD Group to All AD Groups in the Organization?


This filterString gets all AD users from a specific AD group, I need to change this to get ALL users from ALL groups in my organization. I have read through dozens of similar questions and changed this string around several times and cannot find the solution.

  String filterString = "(&(objectCategory=user)(memberOf=cn=" + this.ldapUserSearch + ",ou=Groups,OU=Organization,dc=organizationsoftware,dc=com))";

Solution

  • You can try the following filter, which includes an attribute presence clause:

    (&(objectCategory=user)(memberOf=*))
    

    This will return every user whose memberOf attribute is set to any value. This should have the effect of retrieving all users from all groups.