I found this example that was claimed to be working:
try
{
DirectoryEntry iis = new DirectoryEntry("IIS://localhost/w3svc");
foreach(DirectoryEntry site in iis.Children)
{
if(site.SchemaClassName == "IIsWebServer")
{
if(domain.Equals(site.Properties["ServerComment"].Value.ToString()))
{
return
}
}
}
}
catch(Exception e)
{
...
}