Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

140 lines
3.1 KiB

  1. '
  2. 'Description:
  3. '--------------
  4. 'This example shows you how to use IIS admin objects to get security settings on certain directory
  5. '
  6. 'usage :cscript GetDirSecurity.vbs <adsipath>
  7. 'example :csript GetDirSecurity.vbs IIS://localhost/W3SVC/1/ROOT
  8. '
  9. '
  10. ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  11. Option Explicit
  12. If Wscript.Arguments.Count <>1 then
  13. UsageMsg
  14. End if
  15. Call GetSecuritySettings(UCASE(Wscript.Arguments(0)))
  16. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  17. 'function : Get securitySettings on specified adspath
  18. 'intput : adspath. such as IIS://localhost/W3SVC/n/ROOT/IISSamples
  19. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  20. sub GetSecuritySettings(adspath)
  21. Dim oNode, oIPSecurity
  22. Dim aIP, aDomain
  23. On Error resume next
  24. set oNode= GetObject(adspath)
  25. if Err.Number <>0 then
  26. Wscript.Echo "Err: adspath is incorrect!" & adspath
  27. Wscript.Quit
  28. end if
  29. ' Display authentication settings
  30. Wscript.Echo "Authentication Setting for " & adspath
  31. if oNode.AuthAnonymous then
  32. Wscript.Echo space(2) & "Anonymous authentication enabled"
  33. else
  34. Wscript.Echo space(2) & "Anonymous authentication disabled"
  35. end if
  36. if oNode.AuthBasic then
  37. Wscript.Echo space(2) & "AuthBasic authentication enabled"
  38. else
  39. Wscript.Echo space(2) & "AuthBasic authentication disabled"
  40. end if
  41. if oNode.AuthNTLM then
  42. Wscript.Echo space(2) & "AuthNTLM authentication enabled"
  43. else
  44. Wscript.Echo space(2) & "AuthNTLM authentication disabled"
  45. end if
  46. ' Display secure communication settings
  47. Wscript.Echo
  48. Wscript.Echo "Secure communication settings for " & adspath
  49. if oNode.AccessSSL then
  50. Wscript.Echo space(2) & "Require SSL"
  51. else
  52. Wscript.Echo space(2) & "Not require SSL"
  53. end if
  54. if oNode.AccessSSLRequireCert then
  55. Wscript.Echo space(2) & "Require client certificate"
  56. else
  57. Wscript.Echo space(2) & "Not require client certificate"
  58. end if
  59. if oNode.AccessSSLMapCert then
  60. Wscript.Echo space(2) & "Client certificate mapping is enabled"
  61. else
  62. Wscript.Echo space(2) & "Client certificate mapping is not enabled"
  63. end if
  64. ' Display IP and Domain restriction settings
  65. Wscript.Echo
  66. Wscript.Echo "IP and Domain restriction settings for " & adspath
  67. set oIPSecurity= oNode.IPSecurity
  68. if oIPSecurity.GrantbyDefault then
  69. Wscript.Echo " Grant access except following list"
  70. aIP =oIPSecurity.IPDeny
  71. aDomain=oIPSecurity.DomainDeny
  72. call DisplayList(aIPList)
  73. call DisplayList(aDomainList)
  74. else
  75. 'Wscript.Echo " Deny access except following list"
  76. aIP =oIPSecurity.IPGrant
  77. aDomain=oIPSecurity.DomainGrant
  78. call DisplayList(aIP)
  79. call DisplayList(aDomain)
  80. end if
  81. set oNode=nothing
  82. end sub
  83. 'Display list
  84. Sub DisplayList(List)
  85. Dim cList, i
  86. if IsArray(List) then
  87. cList=UBound(List)
  88. if cList>=0 then
  89. for i=0 to cList
  90. Wscript.Echo space(2) & List(i)
  91. Next
  92. end if
  93. end if
  94. end sub
  95. ' Displays usage message, then QUITS
  96. Sub UsageMsg
  97. Wscript.Echo "Usage: cscript GetDirSecurity.vbs <adspath> "
  98. Wscript.Quit
  99. End Sub