This discussion is archived
2 Replies Latest reply: Jul 21, 2012 9:31 PM by EJP RSS

Get all groups from an AD Server

937672 Newbie
Currently Being Moderated
Hi everyone,

I'm trying to get all groups from and AD server.

Here's how I'm doing it:
DirContext ctx = new InitialDirContext( (Hashtable<String,String>) env);

          Name n2 = new CompositeName().add(groupsContainer);
          NamingEnumeration<Binding> contentsEnum = ctx.listBindings(n2);

          int i = 1;
          while ( contentsEnum.hasMore() && (i++) < 1000 )
               Binding binding =;


          return groups; 
The problem is, I always get an error if I don't restrict the results number to below 1000.

The error is the following *javax.naming.SizeLimitExceededException: [LDAP: error code 4 - Sizelimit Exceeded];*

After googling, I found it it's due to a field in the AD Server, that restrict the result number.

So there is no way that I can obtain all groups without changing that field?



  • Correct Answers - 10 points
  • Helpful Answers - 5 points