title: Iterate a group in active directory using C Sharp
body: <p>I need to be able to execute a program from any server that could iterate through a group in active directory and check certain properties of the users in that group. This is what I have so far:</p>
  
  <pre><code>public static bool searchUser(string domain, string userName, string password, string objectDN)
  {
      DirectoryEntry obj = new DirectoryEntry("LDAP://" + domain + "/" + objectDN, userName, password);
      if (obj.Properties["objectCategory"].ToString().Equals("group"))
      {
          object users = obj.Invoke("Members", null);
          foreach (object members in users) 
          { }
      }
  }
  </code></pre>