I have two types of user accounts on my computer i.e. local users and domain users. I am trying to get the list of all users in all domains. I am using the following code in C#
string sPath = "WinNT://" + Environment.MachineName + ",computer";
using (var computerEntry = new DirectoryEntry(sPath))
foreach (DirectoryEntry childEntry in computerEntry.Children)
if (childEntry.SchemaClassName == "User")
{
MessageBox.Show(childEntry.Name);
}
But I am only getting the local users, not domain users. What would be the better solution ?