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.

378 lines
10 KiB

  1. VERSION 5.00
  2. Begin VB.Form frmMetaData
  3. Caption = "Edit"
  4. ClientHeight = 4650
  5. ClientLeft = 60
  6. ClientTop = 345
  7. ClientWidth = 5940
  8. LinkTopic = "Form1"
  9. ScaleHeight = 4650
  10. ScaleWidth = 5940
  11. StartUpPosition = 3 'Windows Default
  12. Begin VB.CommandButton Cancel
  13. Cancel = -1 'True
  14. Caption = "Cancel"
  15. Height = 495
  16. Left = 4560
  17. TabIndex = 17
  18. Top = 4080
  19. Width = 1095
  20. End
  21. Begin VB.CommandButton OK
  22. Caption = "OK"
  23. Default = -1 'True
  24. Height = 495
  25. Left = 3120
  26. TabIndex = 16
  27. Top = 4080
  28. Width = 1095
  29. End
  30. Begin VB.CheckBox CheckRefAttr
  31. Caption = "By Reference"
  32. Height = 375
  33. Left = 2760
  34. TabIndex = 15
  35. Top = 1920
  36. Width = 3255
  37. End
  38. Begin VB.CheckBox CheckSecureAttr
  39. Caption = "Secure"
  40. Height = 375
  41. Left = 2760
  42. TabIndex = 14
  43. Top = 1440
  44. Width = 3255
  45. End
  46. Begin VB.CheckBox CheckInheritAttr
  47. Caption = "Inherited"
  48. Height = 375
  49. Left = 2760
  50. TabIndex = 13
  51. Top = 960
  52. Width = 3015
  53. End
  54. Begin VB.TextBox UserTypeLabel
  55. Height = 375
  56. Left = 3600
  57. TabIndex = 11
  58. Text = "Text3"
  59. Top = 360
  60. Width = 2295
  61. End
  62. Begin VB.TextBox StringLabel
  63. Height = 375
  64. Left = 720
  65. TabIndex = 9
  66. Text = "Text1"
  67. Top = 2880
  68. Width = 5055
  69. End
  70. Begin VB.TextBox DwordHexLabel
  71. Enabled = 0 'False
  72. Height = 375
  73. Left = 720
  74. TabIndex = 5
  75. Text = "Text2"
  76. Top = 3600
  77. Width = 2295
  78. End
  79. Begin VB.TextBox DwordDecLabel
  80. Height = 375
  81. Left = 720
  82. TabIndex = 4
  83. Text = "Text1"
  84. Top = 2880
  85. Width = 2295
  86. End
  87. Begin VB.OptionButton RadioBinary
  88. Caption = "Binary"
  89. Enabled = 0 'False
  90. Height = 375
  91. Left = 360
  92. TabIndex = 3
  93. Top = 2160
  94. Width = 1935
  95. End
  96. Begin VB.OptionButton RadioMultiSz
  97. Caption = "Multi-String"
  98. Enabled = 0 'False
  99. Height = 375
  100. Left = 360
  101. TabIndex = 2
  102. Top = 1680
  103. Width = 1935
  104. End
  105. Begin VB.OptionButton RadioString
  106. Caption = "String"
  107. Enabled = 0 'False
  108. Height = 375
  109. Left = 360
  110. TabIndex = 1
  111. Top = 1200
  112. Width = 1935
  113. End
  114. Begin VB.OptionButton RadioDword
  115. Caption = "DWORD"
  116. Enabled = 0 'False
  117. Height = 375
  118. Left = 360
  119. TabIndex = 0
  120. Top = 720
  121. Width = 1935
  122. End
  123. Begin VB.Frame Frame1
  124. Caption = "Data Type"
  125. Height = 2415
  126. Left = 120
  127. TabIndex = 10
  128. Top = 240
  129. Width = 2415
  130. End
  131. Begin VB.Label LabelUserType
  132. Caption = "User Type"
  133. Height = 375
  134. Left = 2760
  135. TabIndex = 12
  136. Top = 360
  137. Width = 1215
  138. End
  139. Begin VB.Label LabelString
  140. Caption = "String"
  141. Height = 255
  142. Left = 120
  143. TabIndex = 8
  144. Top = 2880
  145. Width = 855
  146. End
  147. Begin VB.Label LabelHex
  148. Caption = "Hex"
  149. Height = 375
  150. Left = 120
  151. TabIndex = 7
  152. Top = 3600
  153. Width = 615
  154. End
  155. Begin VB.Label LabelDecimal
  156. Caption = "Decimal"
  157. Height = 255
  158. Left = 120
  159. TabIndex = 6
  160. Top = 2880
  161. Width = 615
  162. End
  163. End
  164. Attribute VB_Name = "frmMetaData"
  165. Attribute VB_GlobalNameSpace = False
  166. Attribute VB_Creatable = False
  167. Attribute VB_PredeclaredId = True
  168. Attribute VB_Exposed = False
  169. Private Path As String ' Path of the item
  170. Private ID As Long ' Metabase property ID
  171. Option Explicit
  172. Public Sub SetData(strPath As String, strItem As String)
  173. Dim mb As IMSMetaBase
  174. Set mb = CreateObject("IISAdmin.Object")
  175. Dim key As IMSMetaKey
  176. Dim NewHandle As Long
  177. Dim NullPath() As Byte
  178. Dim bytePath() As Byte
  179. Dim MetaData As IMSMetaDataItem
  180. Dim NewDataValue As Long
  181. ID = Val(strItem)
  182. Path = strPath
  183. ' Open the selected node
  184. NullPath = StrConv("" & Chr(0), vbFromUnicode)
  185. Debug.Print ("Showing " & strPath)
  186. Err.Clear
  187. bytePath = StrConv(strPath & Chr(0), vbFromUnicode)
  188. Set key = mb.OpenKey(1, 100, bytePath)
  189. Set MetaData = key.DataItem
  190. If (Err.Number <> 0) Then
  191. Debug.Print ("Open Meta Object Error Code = " & Err.Number)
  192. Err.Clear
  193. Exit Sub
  194. End If
  195. ' Enumerate the properties on this node
  196. MetaData.UserType = 0
  197. MetaData.DataType = 0
  198. MetaData.Attributes = 0
  199. MetaData.Identifier = ID
  200. key.GetData MetaData
  201. 'mb.AutoADMGetMetaData NewHandle, NullPath, MetaData
  202. If (Err.Number <> 0) Then
  203. MsgBox "GetMetaData Error Code = " & Err.Number & " (" & Err.Description & ")"
  204. Err.Clear
  205. GoTo CloseMb
  206. End If
  207. strItem = MetaData.Identifier
  208. ' Add the user type
  209. If (MetaData.UserType = 1) Then
  210. UserTypeLabel.Text = "IIS_MD_UT_SERVER"
  211. ElseIf (MetaData.UserType = 2) Then
  212. UserTypeLabel.Text = "IIS_MD_UT_FILE"
  213. Else
  214. UserTypeLabel.Text = Str(MetaData.UserType)
  215. End If
  216. ' Do the appropriate datatype conversion
  217. NewDataValue = MetaData.DataType
  218. If (NewDataValue = 1) Then
  219. RadioDword.Value = True
  220. DwordDecLabel.Text = MetaData.Value
  221. DwordHexLabel.Text = Hex(MetaData.Value)
  222. ' Hide the string control and move it to the back
  223. LabelString.Visible = False
  224. StringLabel.Visible = False
  225. LabelString.ZOrder (1)
  226. ElseIf (NewDataValue = 2) Then
  227. Dim j As Long
  228. Dim tmpStr As String
  229. RadioString.Value = True
  230. j = 0
  231. tmpStr = ""
  232. Do While (MetaData.Value(j) <> 0)
  233. tmpStr = tmpStr & Chr(MetaData.Value(j))
  234. j = j + 1
  235. Loop
  236. StringLabel.Text = tmpStr
  237. ' Hide the DWORD controls
  238. DwordDecLabel.Visible = False
  239. DwordDecLabel.ZOrder (1)
  240. LabelDecimal.ZOrder (1)
  241. DwordHexLabel.Visible = False
  242. LabelHex.Visible = False
  243. LabelDecimal.Visible = False
  244. End If
  245. ' Set the attributes checkboxes
  246. If MetaData.Attributes And 1 Then
  247. CheckInheritAttr.Value = Checked
  248. Else
  249. CheckInheritAttr.Value = Unchecked
  250. End If
  251. If MetaData.Attributes And 4 Then
  252. CheckSecureAttr.Value = Checked
  253. Else
  254. CheckSecureAttr.Value = Unchecked
  255. End If
  256. If MetaData.Attributes And 8 Then
  257. CheckRefAttr.Value = Checked
  258. Else
  259. CheckRefAttr.Value = Unchecked
  260. End If
  261. CloseMb:
  262. End Sub
  263. Private Sub Cancel_Click()
  264. Unload Me
  265. End Sub
  266. Private Sub OK_Click()
  267. Dim mb As MSAdmin
  268. Set mb = CreateObject("IISAdmin.Object")
  269. Dim key As IMSMetaKey
  270. Dim NewHandle As Long
  271. Dim NullPath() As Byte
  272. Dim bytePath() As Byte
  273. Dim MetaData As IMSMetaDataItem
  274. Dim NewDataValue As Long
  275. ' Open the selected node
  276. NullPath = StrConv("" & Chr(0), vbFromUnicode)
  277. Err.Clear
  278. bytePath = StrConv(Path & Chr(0), vbFromUnicode)
  279. Set key = mb.OpenKey(2, , bytePath)
  280. If (Err.Number <> 0) Then
  281. Debug.Print ("Open Meta Object Error Code = " & Err.Number)
  282. Err.Clear
  283. Exit Sub
  284. End If
  285. Set MetaData = key.DataItem
  286. MetaData.Identifier = ID
  287. ' Add the user type
  288. If (UserTypeLabel.Text = "IIS_MD_UT_SERVER") Then
  289. MetaData.UserType = 1
  290. ElseIf UserTypeLabel.Text = "IIS_MD_UT_FILE" Then
  291. MetaData.UserType = 2
  292. Else
  293. MetaData.UserType = Val(UserTypeLabel.Text)
  294. End If
  295. ' Do the appropriate datatype conversion
  296. Dim Value As Long
  297. If (RadioDword.Value = True) Then
  298. MetaData.DataType = 1
  299. Value = Val(DwordDecLabel.Text)
  300. MetaData.Value = Value 'Val(DwordDecLabel.Text)
  301. ElseIf (RadioString.Value = True) Then
  302. bytePath = StrConv(StringLabel.Text & Chr(0), vbFromUnicode)
  303. MetaData.DataType = 2
  304. MetaData.Value = bytePath
  305. Else
  306. MsgBox ("Type is not supported")
  307. End If
  308. ' Set the attributes checkboxes
  309. MetaData.Attributes = 0
  310. If (CheckInheritAttr.Value = Checked) Then
  311. MetaData.Attributes = MetaData.Attributes + 1
  312. End If
  313. If (CheckSecureAttr.Value = Checked) Then
  314. MetaData.Attributes = MetaData.Attributes + 4
  315. End If
  316. If (CheckRefAttr.Value = Checked) Then
  317. MetaData.Attributes = MetaData.Attributes + 8
  318. End If
  319. key.SetData MetaData
  320. If (Err.Number <> 0) Then
  321. MsgBox "GetMetaData Error Code = " & Err.Number & " (" & Err.Description & ")"
  322. Err.Clear
  323. GoTo CloseMb
  324. End If
  325. CloseMb:
  326. Unload Me
  327. ' Refresh the listbox and dismiss the dialog
  328. End Sub