title: Get users that are 'memberof' a group
body: <p>I got a working solution, however I'm pretty sure there is a less resource-intensive method because the current solution involves doing a query to get the groups member and then a query to get each users information. </p>
  
  <p>Here is the code I have :</p>
  
  <pre><code>DirectoryEntry root = new DirectoryEntry( "LDAP://server:port" );
  DirectorySearcher searcher = new DirectorySearcher( root );
  searcher.Filter = "(&amp;(ObjectClass=Group)(CN=foo-group))";
  
  var members = (IEnumerable)searcher.FindOne()
                .GetDirectoryEntry()
                .Invoke( "members" );
  
  Dictionary&lt;string , string&gt; results = new Dictionary&lt;string , string&gt;();
  
  foreach( object member in members ) {
     DirectoryEntry de = new DirectoryEntry( member );
     results.Add( de.Properties[ "SAMAccountname" ][ 0 ].ToString(), de.Properties[ "cn" ][ 0 ].ToString() );
  }
  </code></pre>
  
  <p>Ideally I'd like to be able to do a single query to get every user that are member of a group, filters the properties to load and then display them. So something like this</p>
  
  <pre><code>DirectoryEntry root = new DirectoryEntry( "LDAP://server:port" );
  DirectorySearcher searcher = new DirectorySearcher( root );
  searcher.PropertiesToLoad.Add( "cn" );
  searcher.PropertiesToLoad.Add( "SAMAccountname" );
  searcher.Filter = "(&amp;(ObjectClass=user)(memberof=foo-group))";
  
  foreach( var user in searcher.FindAll() ) {
      //do whatever...
  }
  </code></pre>
  
  <p>Unfortunately, that doesn't work for some reason.</p>