I have some hosts on my Win2k box running IIS 5.
One host has it's DNS entry. I want to add virual directories that some
collegues can watch my work progress.
I want to list the virtual directories if they simply enter the
My code looks like so:
Host =3D Request.ServerVariables("SERVER_NAME")
set objWebSvc =3D GetObject("IIS://Localhost/W3svc")
for each obj in objWebSvc
if obj.Class=3D"IIsWebServer" then
if lcase(obj.ServerComment)=3Dlcase(Host) then
set objSite =3D objWebSvc.GetObject("IIsWebServer", obj.Name)
set objRoot=3DobjSite.GetObject("IIsWebVirtualDir", "Root")
for each objDir in objRoot
if objDir.Class=3D"IIsWebVirtualDir" then
Response.Write "<a href=3D""/" & objDir.Name &
""">" & objDir.Name & "</a><br>" & vbLf
My problem is I have to iterate through all object of class
"IIsWebServer" returned by Getobject(...) to find the host whose virtual
(sub)direrctories I want to list. The problem is windows only knows a
number for each host. This number is the name of the host. I'm not
interested in this number. I only know what is stored in the
ServerComment-member of the IIsWebServer-object. The GetObjectMethod of
the IIsWebServer-object only accepts the number as second parameter, not
the ServerComment although some codes I found on the web seemingly
passed the "HostName" (ServerComment).
My question is if there's a simpler way to access a certain host by it's
name via ADSI than to iterate through 'em all..