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.

163 lines
4.2 KiB

  1. '------------------------------------------------------------------------------------------------
  2. '
  3. '
  4. ' Usage: chaccess <--ADSPath|-a relative config store path>
  5. ' [--computer|-c COMPUTER1[,COMPUTER2...]]
  6. ' [+read|-read]
  7. ' [+write|-write]
  8. ' [+script|-script]
  9. ' [+execute|-execute]
  10. ' [+browse|-browse]
  11. ' [--verbose|-v]
  12. ' [--help|-?]
  13. '
  14. ' ADSPATH The ADSI Path of the virtual root in question
  15. '
  16. ' Example 1: chaccess -a w3svc/1/ROOT +read -write +script +browse
  17. '------------------------------------------------------------------------------------------------
  18. ' Force explicit declaration of all variables
  19. Option Explicit
  20. On Error Resume Next
  21. Const Error_NoNode = "Unable to open specified node."
  22. Dim oArgs, ArgNum, verbose, propNum, ArgPath
  23. Dim ArgComputers
  24. Dim prop(15,2)
  25. verbose = false
  26. propNum = 0
  27. ArgNum = 0
  28. ArgPath = ""
  29. ArgComputers = Array("LocalHost")
  30. Set oArgs = WScript.Arguments
  31. While ArgNum < oArgs.Count
  32. Select Case LCase(oArgs(ArgNum))
  33. Case "--adspath", "-a":
  34. ArgNum = ArgNum + 1
  35. ArgPath = oArgs(ArgNum)
  36. Case "--computer","-c":
  37. ArgNum = ArgNum + 1
  38. ArgComputers = Split(oArgs(ArgNum), ",", -1)
  39. Case "--verbose", "-v":
  40. verbose = true
  41. Case "-read":
  42. prop(propNum,0) = "AccessRead"
  43. prop(propNum,1) = false
  44. propNum = propNum + 1
  45. Case "+read":
  46. prop(propNum,0) = "AccessRead"
  47. prop(propNum,1) = true
  48. propNum = propNum + 1
  49. Case "-write":
  50. prop(propNum, 0) = "AccessWrite"
  51. prop(propNum, 1) = false
  52. propNum = propNum + 1
  53. Case "+write":
  54. prop(propNum, 0) = "AccessWrite"
  55. prop(propNum, 1) = true
  56. propNum = propNum + 1
  57. Case "-script":
  58. prop(propNum, 0) = "AccessScript"
  59. prop(propNum, 1) = false
  60. propNum = propNum + 1
  61. Case "+script":
  62. prop(propNum, 0) = "AccessScript"
  63. prop(propNum, 1) = true
  64. propNum = propNum + 1
  65. Case "-execute":
  66. prop(propNum, 0) = "AccessExecute"
  67. prop(propNum, 1) = false
  68. propNum = propNum + 1
  69. Case "+execute":
  70. prop(propNum, 0) = "AccessExecute"
  71. prop(propNum, 1) = true
  72. propNum = propNum + 1
  73. Case "-browse":
  74. prop(propNum, 0) = "EnableDirBrowsing"
  75. prop(propNum, 1) = false
  76. propNum = propNum + 1
  77. Case "+browse":
  78. prop(propNum, 0) = "EnableDirBrowsing"
  79. prop(propNum, 1) = true
  80. propNum = propNum + 1
  81. Case "--help","-?":
  82. Call DisplayUsage
  83. Case Else:
  84. Call DisplayUsage
  85. End Select
  86. ArgNum = ArgNum + 1
  87. Wend
  88. If (ArgPath="") Then
  89. Call DisplayUsage
  90. End If
  91. Dim compIndex
  92. for compIndex = 0 to UBound(ArgComputers)
  93. Call ASTSetPerms(ArgComputers(compIndex), ArgPath, prop, propNum)
  94. next
  95. Sub ASTSetPerms(Computer, Path, propList, propCount)
  96. On Error Resume Next
  97. Dim oAdmin
  98. Dim fullPath
  99. fullPath = "IIS://"&Computer&"/"&Path
  100. Trace "Opening path " & fullPath
  101. Set oAdmin = GetObject(fullPath)
  102. If Err.Number <> 0 Then
  103. Display Error_NoNode
  104. WScript.Quit (1)
  105. End If
  106. Dim name, val
  107. if propCount > 0 then
  108. Dim i
  109. for i = 0 to propCount-1
  110. name = propList(i,0)
  111. val = propList(i,1)
  112. if verbose = true then
  113. Trace "Setting "&fullPath&"/"&name&" = "& val
  114. end if
  115. oAdmin.Put name, (val)
  116. If Err <> 0 Then
  117. Display "Unable to set property "&name
  118. End If
  119. next
  120. oAdmin.SetInfo
  121. If Err <> 0 Then
  122. Display "Unable to save updated information."
  123. End If
  124. end if
  125. End Sub
  126. Sub Display(Msg)
  127. WScript.Echo Now & ". Error Code: " & Hex(Err) & " - " & Msg
  128. End Sub
  129. Sub Trace(Msg)
  130. if verbose = true then
  131. WScript.Echo Now & " : " & Msg
  132. end if
  133. End Sub
  134. Sub DisplayUsage
  135. WScript.Echo "Usage: chaccess <--ADSPath|-a ADSPATH>"
  136. WScript.Echo " [--computer|-c COMPUTER1[,COMPUTER2...]]"
  137. WScript.Echo " [+read|-read]"
  138. WScript.Echo " [+write|-write]"
  139. WScript.Echo " [+script|-script]"
  140. WScript.Echo " [+execute|-execute]"
  141. WScript.Echo " [+browse|-browse]"
  142. WScript.Echo " [--verbose|-v]"
  143. WScript.Echo " [--help|-?]"
  144. WScript.Echo "Example 1: chaccess -a w3svc/1/ROOT +read -write +script +browse"
  145. WScript.Echo "Example 2: chaccess -c MACHINE1,MACHINE2,MACHINE3 -a w3svc/1/ROOT +read -write +script +browse"
  146. WScript.Quit (1)
  147. End Sub