title: How to get all Ldap Groups of a user including nested groups in JAVA
body: <p>I want to find all the groups a user is part of, including nested groups.
  Like if user is part of group A1 and group A1 is part of A, then I want to get A as well.</p>
  
  <p>Following is code , I have tried variuos filterstrings... but nothing is given expected output.</p>
  
  <pre><code>String samAccountName = "group";
  
  String searchFilter = "(&amp;(objectclass=user)(memberof: 1.2.840.113556.1.4.1941:="+samAccountName+"))";
  
  //String searchFilter = "(&amp;(objectCategory=person)(memberOf=CN="+samAccountName+"))";
  
  //String searchFilter = "(&amp;(objectcategory=user)(memberof=CN="+samAccountName+",OU=Users,DC=new,DC=com))";
  
  String searchBase = "DC=new,DC=com";
  
  NamingEnumeration answer = ctx.search(searchBase, searchFilter, ontrols);
               List rolesList = new ArrayList();
              while(answer.hasMoreElements()){
                  SearchResult sr = (SearchResult)answer.next();
  </code></pre>
  
  <p>...</p>
  
  <p>Any help is appreciated.            </p>