Hi, is it possible to querry an Active Directory for servers? In detail i want to retrieve information about instances of MS Sql-/Sharepoint-/IIS-/ and AnalysisService-servers of a domain using C#. Which attributes do i have to check in order to find out which service is running on a machine? If it is not possible to get this information from Active Directory, any other ideas are welome.
Here's a CodeProject article which creates and demonstrates a general-purpose network server enumerator - you can pick what type of server(s) you're interested in, and have a list of server matching that criteria enumerated from your network. It uses routines from the netapi32.dll and surfaces them in a nice, C# compatible way.
Pretty slick stuff!
In AD, of course, you could also enumerate the servers based on the ObjectCategory - but I'm not sure if and how you could distinguish them into separate roles (SQL server, DC etc.).
Another CodeProject article shows how to enumerate objects in general in AD - you can definitely enumerate the computers (objectCategory=computer
) from AD, but I'm not sure you can limit what you'll get back ahead of time with an LDAP filter...