How to

enumerate local network computers using Active Directory

Published: 31. January 2012 | Updated: 31. January 2012
License: Microsoft Public License (MS-PL)
Categories: Network
Tags: C# Network Windows
Was this snippet helpful for you? YESYES / NONO

Import namespace

using System.DirectoryServices;

Code

var root = new DirectoryEntry("WinNT:");
foreach (DirectoryEntry entry in root.Children)
{
    foreach (DirectoryEntry item in entry.Children)
    {
        if (item.Name.Equals("Schema")) continue;
        Console.WriteLine(item.Name);
    }
}
Send us feedback about this snippet »



Related Snippets: