title: How to get all existing groups in jcr?
body: <p>I want to fetch a list of all existing groups in CQ5 JCR. I am able to fetch a list of all existing users in the JCR using following code,</p>
  
  <pre><code>        UserManager userManager = jkrSession.getUserManager();
          final List&lt;String&gt; users = new ArrayList&lt;String&gt;();
          Iterator&lt;Authorizable&gt; iter = userManager.findAuthorizables(
                "jcr:primaryType", "rep:User");
          while (iter.hasNext()) {
          Authorizable auth = iter.next();
          if (!auth.isGroup()) {
                          users.add(auth.getID());
                  }
          }
  </code></pre>
  
  <p>I haven't found any way to get a list of all existing users. Although, I can see the parent nodes /home/users and /home/groups and I can iterate over the child nodes to fetch users and groups. </p>
  
  <p>I am looking for an easier way out.</p>