I wrote a monitoring program for IIS servers ( each Site under the IIS
/service/ is known as a *server* ).
This code (below) works on w2k, but not on w2003 and I think it might
just be naming conventions.
In w2k, each new site is indexed in active directory like:
W3SVC/1
W3SVC/2
....
W3SVC/n
In w2003 that doesn't seem to be the case. For one thing, if I look in
the logFiles directory, I see that the first service is labelled
W3SVC/1, but the next one is labelled W3SVC/2nnnnnn..., likewise, the
next is labelled W3SVC/3nnnnnnnn...
When I run my code using either W3SVC/2 or the extended number I see in
LogFiles, it errors and says "not found".
How can I control my additional sites from WMI using .NET?
using System;
using System.DirectoryServices;
namespace Webeye
{
/// <summary>
/// Summary description for iism2m.
/// </summary>
public class iism2m
{
DirectoryEntry _root;
public iism2m(string _serverName)
{
//
// TODO: Add constructor logic here
//
_root = new DirectoryEntry("IIS://localhost/"+_serverName);
//"/W3SVC/1");
}
public void start()
{
_root.Invoke("start"); // and start
}
public void stop()
{
_root.Invoke("stop"); // stop
}
}
}