Leaked source code of windows server 2003
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.

302 lines
9.8 KiB

  1. <HTML>
  2. <HEAD>
  3. <TITLE>Add then delete a key and properties</TITLE>
  4. </HEAD>
  5. <BODY>
  6. <%
  7. 'Metabase Constants
  8. Const METADATA_NO_ATTRIBUTES = &H0
  9. Const METADATA_INHERIT = &H00000001
  10. Const METADATA_PARTIAL_PATH = &H00000002
  11. Const METADATA_SECURE = &H00000004
  12. Const METADATA_REFERENCE = &H00000008
  13. Const METADATA_VOLATILE = &H00000010
  14. Const METADATA_ISINHERITED = &H00000020
  15. Const METADATA_INSERT_PATH = &H00000040
  16. Const IIS_MD_UT_SERVER = 1
  17. Const IIS_MD_UT_FILE = 2
  18. Const IIS_MD_UT_WAM = 100
  19. Const ASP_MD_UT_APP = 101
  20. Const ALL_METADATA = 0
  21. Const DWORD_METADATA = 1
  22. Const STRING_METADATA = 2
  23. Const BINARY_METADATA = 3
  24. Const EXPANDSZ_METADATA = 4
  25. Const MULTISZ_METADATA = 5
  26. 'Carrage Return + Line Feed pair
  27. Dim CRLF
  28. CRLF = CHR(13) + CHR(10)
  29. Sub DisplayProperty(ByRef objProperty, ByRef strIndent)
  30. Dim strId
  31. Dim strAttr
  32. Dim intAttr
  33. Dim strUserType
  34. Dim intUserType
  35. Dim strDataType
  36. Dim intDataType
  37. Dim strData
  38. Dim i
  39. Dim arData
  40. strId = CStr(objProperty.Id)
  41. intAttr = objProperty.Attributes
  42. strAttr = " "
  43. If ((intAttr And METADATA_INHERIT) = METADATA_INHERIT) Then
  44. strAttr = strAttr & "inherit "
  45. End If
  46. If ((intAttr And METADATA_PARTIAL_PATH) = METADATA_PARTIAL_PATH) Then
  47. strAttr = strAttr & "partial_path "
  48. End If
  49. If ((intAttr And METADATA_SECURE) = METADATA_SECURE) Then
  50. strAttr = strAttr & "secure "
  51. End If
  52. If ((intAttr And METADATA_REFERENCE) = METADATA_REFERENCE) Then
  53. strAttr = strAttr & "reference "
  54. End If
  55. If ((intAttr And METADATA_VOLATILE) = METADATA_VOLATILE) Then
  56. strAttr = strAttr & "volatile "
  57. End If
  58. If ((intAttr And METADATA_ISINHERITED) = METADATA_ISINHERITED) Then
  59. strAttr = strAttr & "isinherited "
  60. End If
  61. If ((intAttr And METADATA_INSERT_PATH) = METADATA_INSERT_PATH) Then
  62. strAttr = strAttr & "insert_path "
  63. End If
  64. intUserType = objProperty.UserType
  65. If (intUserType = IIS_MD_UT_SERVER) Then
  66. strUserType = "server"
  67. ElseIf (intUserType = IIS_MD_UT_FILE) Then
  68. strUserType = "file"
  69. ElseIf (intUserType = IIS_MD_UT_WAM) Then
  70. strUserType = "wam"
  71. ElseIf (intUserType = ASP_MD_UT_APP) Then
  72. strUserType = "asp_app"
  73. Else
  74. strUserType = "*unknown*"
  75. End If
  76. intDataType = objProperty.DataType
  77. If (intDataType = ALL_METADATA) Then
  78. strDataType = "*all*"
  79. ElseIf (intDataType = DWORD_METADATA) Then
  80. strDataType = "dword"
  81. ElseIf (intDataType = STRING_METADATA) Then
  82. strDataType = "string"
  83. ElseIf (intDataType = BINARY_METADATA) Then
  84. strDataType = "binary"
  85. ElseIf (intDataType = EXPANDSZ_METADATA) Then
  86. strDataType = "expandsz"
  87. ElseIf (intDataType = MULTISZ_METADATA) Then
  88. strDataType = "multisz"
  89. Else
  90. strDataType = "*unknown*"
  91. End If
  92. 'Don't show secure data
  93. If ((intAttr And METADATA_SECURE) = METADATA_SECURE) Then
  94. strData = "*not displayed*"
  95. ElseIf (intDataType = BINARY_METADATA) Then
  96. 'Display as a list of bytes
  97. strData = ""
  98. For i = 1 To LenB(objProperty.Data)
  99. strData = strData & CInt(AscB(MidB(objProperty.Data, i, 1))) & " "
  100. Next
  101. ElseIf (intDataType = MULTISZ_METADATA) Then
  102. arData = objProperty.Data
  103. 'Display as a an intented list of strings, one on each line
  104. strData = ""
  105. For i = LBound(arData) To UBound(arData)
  106. strData = strData & CRLF & strIndent & " " & arData(i)
  107. Next
  108. Else
  109. strData = CStr(objProperty.Data)
  110. End If
  111. Response.Write(strIndent & strId & " A:" & strAttr & "UT: " & strUserType & _
  112. " DT: " & strDataType & " D: " & StrData & CRLF)
  113. End Sub
  114. Dim MetaUtil
  115. Dim Keys
  116. Dim Key
  117. Dim Properties
  118. Dim Property
  119. 'Create the MetaUtil object
  120. Set MetaUtil = Server.CreateObject("MSWC.MetaUtil.1")
  121. 'Base Key of "LM/W3SVC"
  122. Response.Write("<FONT SIZE=+1>Base key of ""LM/W3SVC/1/ROOT"" </FONT><br>" + CHR(13) + CHR(10))
  123. Response.Write("<br>" + CHR(13) + CHR(10))
  124. Set Keys = MetaUtil.EnumKeys("LM/W3SVC/1/ROOT")
  125. 'Enumerate the keys
  126. Response.Write("Enumerate the Keys:<br>" + CHR(13) + CHR(10))
  127. For Each Key In Keys
  128. Response.Write(Key)
  129. Response.Write("<br>" + CHR(13) + CHR(10))
  130. Next
  131. Response.Write("<br>" + CHR(13) + CHR(10))
  132. 'Create "LM/W3SVC/1/ROOT/ADDRMTEST"
  133. Response.Write("Create ""LM/W3SVC/1/ROOT/ADDRMTEST""<br>" + CHR(13) + CHR(10))
  134. MetaUtil.CreateKey("LM/W3SVC/1/ROOT/ADDRMTEST")
  135. Response.Write("<br>" + CHR(13) + CHR(10))
  136. 'Enumerate the keys
  137. Response.Write("Enumerate the Keys:<br>" + CHR(13) + CHR(10))
  138. For Each Key In Keys
  139. Response.Write(Key)
  140. Response.Write("<br>" + CHR(13) + CHR(10))
  141. Next
  142. Response.Write("<br>" + CHR(13) + CHR(10))
  143. Set Properties = MetaUtil.EnumProperties("LM/W3SVC/1/ROOT/ADDRMTEST")
  144. 'Enumerate the properties
  145. Response.Write("Enumerate the properties under ""LM/W3SVC/1/ROOT/ADDRMTEST"":<br>" + CHR(13) + CHR(10))
  146. Response.Write("<PRE>" + CHR(13) + CHR(10))
  147. For Each Property In Properties
  148. DisplayProperty Property, ""
  149. Next
  150. Response.Write("</PRE>" + CHR(13) + CHR(10))
  151. Response.Write("<br>" + CHR(13) + CHR(10))
  152. 'Create 6016 (Access Flags)
  153. Response.Write("Create 6016 (Access Flags) = 513:<br>" + CHR(13) + CHR(10))
  154. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", 6016)
  155. Property.Attributes = METADATA_INHERIT
  156. Property.UserType = IIS_MD_UT_FILE
  157. Property.DataType = DWORD_METADATA
  158. Property.Data = 513
  159. Property.Write
  160. Response.Write("<br>" + CHR(13) + CHR(10))
  161. 'Create 1099 (Win32 Error)
  162. Response.Write("Create 1099 (Win32 Error) = 0:<br>" + CHR(13) + CHR(10))
  163. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", 1099)
  164. Property.Attributes = METADATA_INHERIT
  165. Property.UserType = IIS_MD_UT_SERVER
  166. Property.DataType = DWORD_METADATA
  167. Property.Data = 0
  168. Property.Write
  169. Response.Write("<br>" + CHR(13) + CHR(10))
  170. 'Create 3001 (Path)
  171. Response.Write("Create 3001 (Path) = c:\temp:<br>" + CHR(13) + CHR(10))
  172. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", 3001)
  173. Property.Attributes = METADATA_INHERIT
  174. Property.UserType = IIS_MD_UT_FILE
  175. Property.DataType = STRING_METADATA
  176. Property.Data = "c:\temp"
  177. Property.Write
  178. Response.Write("<br>" + CHR(13) + CHR(10))
  179. 'Create KeyType (1002)
  180. Response.Write("Create KeyType (1002) = IIsWebVirtualDir:<br>" + CHR(13) + CHR(10))
  181. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", "KeyType")
  182. Property.Attributes = METADATA_NO_ATTRIBUTES
  183. Property.UserType = IIS_MD_UT_SERVER
  184. Property.DataType = STRING_METADATA
  185. Property.Data = "IIsWebVirtualDir"
  186. Property.Write
  187. Response.Write("<br>" + CHR(13) + CHR(10))
  188. 'Create 13001 (Undefined)
  189. Response.Write("Create 13001 (Undefined) = {23 237 64}:<br>" + CHR(13) + CHR(10))
  190. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", 13001)
  191. Property.Attributes = METADATA_NO_ATTRIBUTES
  192. Property.UserType = IIS_MD_UT_SERVER
  193. Property.DataType = BINARY_METADATA
  194. Property.Data = CHRB(23) + CHRB(237) + CHRB(64)
  195. Property.Write
  196. Response.Write("<br>" + CHR(13) + CHR(10))
  197. 'Create 13002 (Undefined)
  198. Response.Write("Create 13002 (Undefined) = {""Hello"" ""World"" ""!""}:<br>" + CHR(13) + CHR(10))
  199. Set Property = MetaUtil.CreateProperty("LM/W3SVC/1/ROOT/ADDRMTEST", 13002)
  200. Property.Attributes = METADATA_NO_ATTRIBUTES
  201. Property.UserType = IIS_MD_UT_SERVER
  202. Property.DataType = MULTISZ_METADATA
  203. Dim arData(3)
  204. arData(0) = "Hello"
  205. arData(1) = "World"
  206. arData(2) = "!"
  207. arData(3) = null
  208. Property.Data = arData
  209. Property.Write
  210. Response.Write("<br>" + CHR(13) + CHR(10))
  211. 'Enumerate the properties
  212. Response.Write("Enumerate the properties under ""LM/W3SVC/1/ROOT/ADDRMTEST"":<br>" + CHR(13) + CHR(10))
  213. Response.Write("<PRE>" + CHR(13) + CHR(10))
  214. For Each Property In Properties
  215. DisplayProperty Property, ""
  216. Next
  217. Response.Write("</PRE>" + CHR(13) + CHR(10))
  218. Response.Write("<br>" + CHR(13) + CHR(10))
  219. 'Delete ACCESSFLAGS (6016)
  220. Response.Write("Delete ACCESSFLAGS (6016):<br>" + CHR(13) + CHR(10))
  221. MetaUtil.DeleteProperty "LM/W3SVC/1/ROOT/ADDRMTEST", "ACCESSFLAGS"
  222. Response.Write("<br>" + CHR(13) + CHR(10))
  223. 'Delete 1002
  224. Response.Write("Delete 1002 (KeyType):<br>" + CHR(13) + CHR(10))
  225. MetaUtil.DeleteProperty "LM/W3SVC/1/ROOT/ADDRMTEST", 1002
  226. Response.Write("<br>" + CHR(13) + CHR(10))
  227. 'Enumerate the properties
  228. Response.Write("Enumerate the properties under ""LM/W3SVC/1/ROOT/ADDRMTEST"":<br>" + CHR(13) + CHR(10))
  229. Response.Write("<PRE>" + CHR(13) + CHR(10))
  230. For Each Property In Properties
  231. DisplayProperty Property, ""
  232. Next
  233. Response.Write("</PRE>" + CHR(13) + CHR(10))
  234. Response.Write("<br>" + CHR(13) + CHR(10))
  235. 'Delete "LM/W3SVC/1/ROOT/ADDRMTEST"
  236. Response.Write("Delete ""LM/W3SVC/1/ROOT/ADDRMTEST""<br>" + CHR(13) + CHR(10))
  237. MetaUtil.DeleteKey("LM/W3SVC/1/ROOT/ADDRMTEST")
  238. Response.Write("<br>" + CHR(13) + CHR(10))
  239. 'Enumerate the keys
  240. Response.Write("Enumerate the Keys:<br>" + CHR(13) + CHR(10))
  241. For Each Key In Keys
  242. Response.Write(Key)
  243. Response.Write("<br>" + CHR(13) + CHR(10))
  244. Next
  245. Response.Write("<br>" + CHR(13) + CHR(10))
  246. Response.Write("Done<br>")
  247. 'Clean up the reference to IIS.MetaUtil
  248. Session.Abandon
  249. %>
  250. </BODY>
  251. </HTML>