'Get windows group members along with their domain names

I have a windows group called "windgrp" it has three members in it:

  • Administrators
  • testDomain.Administrator
  • user1

I have this code to display the members present in a group:

using (DirectoryEntry groupEntry = 
  new DirectoryEntry("WinNT://./" + userGroupName + ",group"))
{
    foreach (object member in (IEnumerable)groupEntry.Invoke("Members"))
    {
        using (DirectoryEntry memberEntry = new DirectoryEntry(member))
        {

            listbox.itms.add(memberentry.name);
        }
    }
}

This gives me the result:

  • Administrator
  • Administrator
  • user

It does not show me to which domain the 2nd entry belongs to.

How can I get the domain?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source