title: How to get all windows groups?
body: <p>I wrote this to get the groups a particular user belongs to:</p>
  
  <pre><code>DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
  DirectoryEntry user = AD.Children.Find(completeUserName, "user");
  object obGroups = AD.Invoke("Groups");
  foreach (object ob in (IEnumerable)obGroups)
  {
     // Create object for each group.
      DirectoryEntry obGpEntry = new DirectoryEntry(ob);
      listOfMyWindowsGroups.Add(obGpEntry.Name);
  }
  for (int j = 0; j &lt; listOfMyWindowsGroups.Count; j++)
  {
     //ex
  }
  </code></pre>
  
  <p>How is it possible to retrieve all the groups in windows and not just for a particular user?</p>