title: How to retrieve Users in a Group, including primary group users
body: <p>I'm working in .net 2.0 and need to retrieve all the users of a given AD group.  I have the following method that does return all the members of the group, but it does not return users that have the passed group as their primary group.  What do I need to do to get those users included as well?</p>
  
  <pre><code>/// &lt;summary&gt;
  /// Gets the group child users.
  /// &lt;/summary&gt;
  /// &lt;param name="parentGroup"&gt;The parent group.&lt;/param&gt;
  /// &lt;returns&gt;&lt;/returns&gt;
  public List&lt;ADUser&gt; GetGroupChildUsers(ADGroup parentGroup)
  {
      List&lt;ADUser&gt; list = new List&lt;ADUser&gt;();
  
      DirectoryEntry entry = GetDirectoryEntry(LdapBaseString);
  
      DirectorySearcher searcher = new DirectorySearcher(entry);
      searcher.Filter = string.Format("(&amp;(objectCategory=person)(memberOf={0}))", parentGroup.DN);
  
      searcher.PropertiesToLoad.Add("objectGUID");
      searcher.SizeLimit = MaxReturnCount;
  
      SearchResultCollection results = searcher.FindAll();
  
      foreach (SearchResult result in results) {
          Guid guid = new Guid((byte[])result.Properties["objectGUID"][0]);
          list.Add(GetUserByGuid(guid));
      }
  
      if (list.Count &lt;= 0) {
          return null;
      } else {
          return list;
      }
  }
  </code></pre>