| Login

Search this Blog


Links I like to keep around




Here are the most recent postings to this blog. Use the archive calendar or search to find other entries.
Nov22

Written by:R Teachout
11/22/2006 6:51 PM

The following script will allow you to process all physcial and virtual directories for a particular web site and show if they allow anonymous access or not.

You must specify the web site instance id.

In the case of Windows XP Pro there is (by default) only one web site which has an instance ID of 1.

If you are running multiple web sites on a Server OS or you have created multiple web sites on XP pro then you can find the web site instance ID by the following method.

  • Right click the web site, select properties, on the web site tab under logging click the Properties button, part of the log file name will contain the web site #

    example log filename: W3SVC1\exyymmdd.log  - the web site is 1
                                     W3SVC45\exyymmdd.log - the web site is 45

Calling Usage:   cscript EnumAnonymousAccessDiabled.vbs  InstanceID

function EnumVirtualDirectories(LevelMachineNameObjectPathDirStyle)
  Dim ChildObjectIISObkect

  on error resume next
  Err.Clear

  IIsObjectPath = "IIS://" & MachineName
  If (ObjectPath = ""Then
    exit function
  else
    IIsObjectPath = IIsObjectPath & "/" & ObjectPath
  End If

  'WScript.Echo "Checking : " & IISObjectPath

  Set IIsObject = GetObject(IIsObjectPath)

  If (Err.Number <> 0Then
    if (Level = 1then
      WScript.Echo "Error: " & Err.Description & " (" & Err.Number & ")"
    end if
    exit function
  End If

  Err.Clear

  For Each ChildObject In IIsObject
    If (Err.Number <> 0Then
      '    WScript.Echo "Error = " & Err.Description
      '      Exit For
    end if

    if (ChildObject.Class = DirStylethen
      ChildObjectName = Right(ChildObject.AdsPathLen(ChildObject.AdsPath- 6)
      ChildObjectName = Right(ChildObjectNameLen(ChildObjectName- InStr(ChildObjectName"/") )

      if (len(ChildObjectName< 60then
        ChildObjectName = ChildObjectName & space(60-len(childObjectName))
      end if
      WScript.Echo ChildObjectName & " - " & ChildObject.AuthAnonymous

      EnumVirtualDirectories Level+1MachineName,  ChildObjectNameDirStyle
    end if
  next

End Function

Sub DisplayHelpMessage()
  WScript.Echo
  WScript.Echo "Usage:"
  WScript.Echo "      EnumAnonymousAccessDisabled.VBS WebSiteNumber"
  WScript.Echo
  WScript.Echo "WebSiteNumber is the number of the web site, you have two methods to determine this:"
  WScript.Echo
  WScript.Echo "#1 = Run FINDWEB.VBS"
  WScript.Echo "#2 = Right click the web site, select properties, on the web site tab"
  WScript.Echo "     under logging click the Properties button, part of the log file"
  WScript.Echo "     name will contain the web site #"
  WScript.Echo
  WScript.Echo "     example log filename: W3SVC1\exyymmdd.log  - the web site is 1"
  WScript.Echo "                           W3SVC45\exyymmdd.log - the web site is 45"
end sub

Const GENERAL_FAILURE = 2

' Get the Arguments object
Set ArgObj = WScript.Arguments

' Test to make sure there is at least one command line arg - the command
If ArgObj.Count < 1 Then
  DisplayHelpMessage
  WScript.Quit (GENERAL_FAILURE)
End If

Servername = "LocalHost"
WebSiteID    = ArgObj(0)
WebSite        = "W3SVC/" & WebSiteID & "/Root"
Level             = 1

WScript.Echo "Allow Anonymous Access"
WScript.Echo ""
WScript.Echo "Virtual Directories for " & WebSite
EnumVirtualDirectories LevelServerNameWebSite"IIsWebVirtualDir"

WScript.Echo ""
WScript.Echo "Physical Directories for " & WebSite
EnumVirtualDirectories LevelServerNameWebSite"IIsWebDirectory"

Download: EnumAnonymousAccessDisabled.vbs

Tags:

On the side of the software box, in the 'System Requirements' section, it said 'Requires Windows 95 or better'. So I installed Linux.
-

Inspired by Nina