Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get list of computers in a domain using .Net

How to get list of computer names in a domain using C# ?

like image 843
user27052 Avatar asked Mar 02 '23 01:03

user27052


1 Answers

using System.DirectoryServices;

public void PrintComputersInDomain (string domainName)
{
    DirectoryEntry de = new DirectoryEntry ("LDAP://" + domainName);
    de.Children.SchemaFilter.Add ("computer");
    foreach (DirectoryEntry c in de.Children)
    {
        Console.WriteLine (c.Name);
    }
}

from http://msmvps.com/blogs/siva/archive/2008/01/25/enumerating-computers-in-a-domain.aspx

like image 121
Hath Avatar answered Mar 11 '23 09:03

Hath