title: How to get a list of groups in an Active Directory group
body: <p>I'm trying to get a list of the groups that are in an AD group using .NET.  </p>
  
  <p>As an example, I have a group called TestGroup and inside that group I have the group DomainAdministrators.  </p>
  
  <p>Using the code below I can get all of the users including those from the DomainAdministrators group but not the group itself.</p>
  
  <pre><code>PrincipalContext ctx = new PrincipalContext(ContextType.Domain, "DomainName");
  GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, "TestGroup");
  
  ArrayList members = new ArrayList();
  
  if (grp != null)
  {
      foreach (Principal p in grp.GetMembers(true))
      {
          members.Add(p.Name)
      }
  
  }   
  grp.Dispose();
  ctx.Dispose();
  </code></pre>
  
  <p>Instead of GetMembers I've tried GetGroups but that doesn't return anything.  How can I return the groups in the group?</p>