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.

410 lines
15 KiB

  1. VERSION 1.0 CLASS
  2. BEGIN
  3. MultiUse = -1 'True
  4. END
  5. Attribute VB_Name = "SiteCtrl"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11. 'Private wsoServices As DIWbemServices
  12. Private wsoServices As ISWbemServices
  13. 'Private wcoContext As DWbemContext
  14. Private wcoContext As New SWbemNamedValueSet
  15. Private sSessionHandle As String
  16. Private lInterpoll As Long
  17. Private iTicker As Integer
  18. Private Sub Class_Initialize()
  19. frmMain.lstModules.AddItem "Site Control File"
  20. frmMain.lstModules.Selected(frmMain.lstModules.ListCount - 1) = False
  21. End Sub
  22. Public Function GetModuleInfo() As String
  23. GetModuleInfo = "As of 5/4, this module is unstable, at best."
  24. End Function
  25. Public Sub RegisterNodes()
  26. frmTest.AddNode "root", "scfRoot", "Site Control File"
  27. frmTest.AddNode "scfRoot", "scfConnect", "Connect"
  28. frmTest.AddNode "scfRoot", "scfGetSessionHandle", "Get SessionHandle"
  29. frmTest.AddNode "scfRoot", "scfContext", "Build Context Object"
  30. frmTest.AddNode "scfRoot", "scfReadInterPoll", "Read Inter-Poll Delay Time"
  31. frmTest.AddNode "scfRoot", "scfModifyInterPoll", "Modify Inter-Poll Delay Time"
  32. frmTest.AddNode "scfRoot", "scfWaitBug", "Verify Changes"
  33. frmTest.AddNode "scfRoot", "scfReleaseSessionHandle", "Release SessionHandle"
  34. End Sub
  35. Public Sub RegisterTests()
  36. Tests.Add "Site Control File", "scfConnect"
  37. Tests.Add "Site Control File", "scfGetSessionHandle"
  38. Tests.Add "Site Control File", "scfContext"
  39. Tests.Add "Site Control File", "scfReadInterPoll"
  40. Tests.Add "Site Control File", "scfModifyInterPoll"
  41. Tests.Add "Site Control File", "scfWait"
  42. Tests.Add "Site Control File", "scfWaitBug"
  43. Tests.Add "Site Control File", "scfReleaseSessionHandle"
  44. End Sub
  45. Public Function Execute(mynode As Node) As Integer
  46. Execute = 0
  47. Select Case mynode.key
  48. Case "scfConnect"
  49. Execute = scfConnect(mynode)
  50. Exit Function
  51. Case "scfGetSessionHandle"
  52. Execute = scfGetSessionHandle(mynode)
  53. Exit Function
  54. Case "scfContext"
  55. Execute = scfContext(mynode)
  56. Exit Function
  57. Case "scfReadInterPoll"
  58. Execute = scfReadInterPoll(mynode)
  59. Exit Function
  60. Case "scfModifyInterPoll"
  61. Execute = scfModifyInterPoll(mynode)
  62. Exit Function
  63. Case "scfWait"
  64. Execute = scfWait(mynode)
  65. Exit Function
  66. Case "scfWaitBug"
  67. Execute = scfWaitBug(mynode)
  68. Exit Function
  69. Case "scfReleaseSessionHandle"
  70. Execute = scfReleaseSessionHandle(mynode)
  71. Exit Function
  72. Case Else
  73. Execute = 3
  74. Exit Function
  75. End Select
  76. Execute = 3
  77. End Function
  78. Private Function scfConnect(n As Node) As Integer
  79. 'Dim wlo As New DWbemLocator
  80. Dim wlo As New SWbemLocator
  81. Dim u As String
  82. Dim p As String
  83. Dim a As String
  84. If frmMain.chkUserid.Value Then
  85. u = vbNullString
  86. Else
  87. u = frmMain.txtUserid.text
  88. End If
  89. If frmMain.chkPassword.Value Then
  90. p = vbNullString
  91. Else
  92. p = frmMain.txtPassword.text
  93. End If
  94. If frmMain.chkAuthority.Value Then
  95. a = vbNullString
  96. Else
  97. a = frmMain.txtAuthority.text
  98. End If
  99. On Error Resume Next
  100. 'wlo.ConnectServer "\\" & frmMain.txtServer.text & "\root\sms\site_" & frmMain.txtSitecode.text, u, p, vbNullString, 0, a, Nothing, wsoServices
  101. Set wsoServices = wlo.ConnectServer(frmMain.txtServer.text, "root\sms\site_" & frmMain.txtSitecode.text, u, p)
  102. If CheckError(Err.Number, n, "Connecting to \\" & frmMain.txtServer.text & "\root\sms\site_" & frmMain.txtSitecode.text) Then Exit Function
  103. scfConnect = 1
  104. End Function
  105. Private Function scfGetSessionHandle(n As Node) As Integer
  106. On Error Resume Next
  107. If Not frmTest.AllOfThesePassed("scfConnect") Then
  108. scfGetSessionHandle = 2
  109. Exit Function
  110. End If
  111. 'Dim out As DWbemClassObject
  112. Dim out As ISWbemObject
  113. 'wsoServices.ExecMethod "sms_sitecontrolfile", "GetSessionHandle", 0, Nothing, Nothing, out, Nothing
  114. Set out = wsoServices.ExecMethod("sms_sitecontrolfile", "getsessionhandle")
  115. If CheckError(Err.Number, n, "ExecMethod SMS_SiteControlFile.GetSessionHandle") Then Exit Function
  116. 'out.Get "SessionHandle", 0, v, 0, 0
  117. If CheckError(Err.Number, n, "Get SessionHandle from Outparam") Then Exit Function
  118. sSessionHandle = CStr(out.SessionHandle)
  119. If CheckError(Err.Number, n, "Get SessionHandle from Outparam") Then Exit Function
  120. n.text = n.text & " " & sSessionHandle
  121. scfGetSessionHandle = 1
  122. End Function
  123. Private Function scfReleaseSessionHandle(n As Node) As Integer
  124. On Error Resume Next
  125. If Not frmTest.AllOfThesePassed("scfGetSessionHandle") Then
  126. scfReleaseSessionHandle = 2
  127. Exit Function
  128. End If
  129. 'Dim c As DWbemClassObject 'inparam
  130. Dim c As ISWbemObject
  131. 'wsoServices.GetObject "__PARAMETERS", 0, Nothing, c, Nothing
  132. Set c = wsoServices.Get("__PARAMETERS")
  133. If CheckError(Err.Number, n, "GetObject __PARAMETERS") Then Exit Function
  134. 'c.Put "SessionHandle", 0, CVar(sSessionHandle), CIM_STRING
  135. c.Properties_.Add "SessionHandle", CIM_STRING
  136. c.SessionHandle = CVar(sSessionHandle)
  137. If CheckError(Err.Number, n, "Get SessionHandle from Outparam") Then Exit Function
  138. 'wsoServices.ExecMethod "SMS_SiteControlFile", "ReleaseSessionHandle", 0, Nothing, c, Nothing, Nothing
  139. wsoServices.ExecMethod "sms_sitecontrolfile", "releasesessionhandle", c
  140. If CheckError(Err.Number, n, "ExecMethod SMS_SiteControlFile.ReleaseSessionHandle") Then Exit Function
  141. scfReleaseSessionHandle = 1
  142. End Function
  143. Private Function scfContext(n As Node) As Integer
  144. On Error Resume Next
  145. If Not frmTest.AllOfThesePassed("scfConnect", "scfGetSessionHandle") Then
  146. scfContext = 2
  147. Exit Function
  148. End If
  149. 'Dim context As New DWbemContext
  150. 'Dim context As New SWbemContext
  151. 'context.SetValue "SessionHandle", 0, CVar(sSessionHandle)
  152. MsgBox "This Module GPF's at this point about 75% of the time" & vbCrLf & _
  153. "Therefore we don't recommend running this module!" & vbCrLf & _
  154. "If it GPF's just restart the sdkbvt and don't select this module"
  155. wcoContext.Add "SessionHandle", CVar(sSessionHandle)
  156. If CheckError(Err.Number, n, "Context SetValue") Then Exit Function
  157. 'Set wcoContext = context
  158. scfContext = 1
  159. End Function
  160. Private Function scfReadInterPoll(n As Node) As Integer
  161. On Error Resume Next
  162. If Not frmTest.AllOfThesePassed("scfContext") Then
  163. scfReadInterPoll = 2
  164. Exit Function
  165. End If
  166. 'Dim c As DWbemClassObject
  167. Dim c As ISWbemObject
  168. Dim bigpath As String
  169. bigpath = "SMS_SCI_Component.FileType=2,ItemName=""SMS_SITE_COMPONENT_MANAGER|" & UCase(frmMain.txtServer.text) & """,ItemType=""Component"",SiteCode=""" & UCase(frmMain.txtSitecode.text) & """"
  170. 'wsoServices.GetObject bigpath, 0, wcoContext, c, Nothing
  171. Set c = wsoServices.Get(bigpath, , wcoContext)
  172. If CheckError(Err.Number, n, "GetObject " & bigpath) Then Exit Function
  173. Dim s As String
  174. 'c.GetObjectText 0, s
  175. s = c.GetObjectText_
  176. n.Tag = n.Tag & ObjText2Text(s)
  177. Dim vary As Variant
  178. 'c.Get "Props", 0, vary, 0, 0 'give up the props, home-boy!
  179. vary = c.Properties_("Props").Value
  180. If CheckError(Err.Number, n, "Get Props") Then Exit Function
  181. Dim i As Integer
  182. Dim v As Variant
  183. For i = LBound(vary) To LBound(vary)
  184. 'vary(i).Get "PropertyName", 0, v, 0, 0
  185. 'If CheckError(Err.Number, n, "Get PropertyName") Then Exit Function
  186. 'If CStr(v) = "Inter-Poll Delay Time" Then
  187. If CStr(vary(i).PropertyName) = "Inter-Poll Delay Time" Then
  188. 'vary(i).Get "Value", 0, v, 0, 0
  189. 'If CheckError(Err.Number, n, "Get Value") Then Exit Function
  190. lInterpoll = CLng(vary(i).Value)
  191. If CheckError(Err.Number, n, "Get Value") Then Exit Function
  192. scfReadInterPoll = 1
  193. Exit Function
  194. End If
  195. Next i
  196. n.Tag = n.Tag & "Inter-Poll Delay Time property could not be found."
  197. scfReadInterPoll = 2
  198. End Function
  199. Private Function scfModifyInterPoll(n As Node) As Integer
  200. On Error Resume Next
  201. If Not frmTest.AllOfThesePassed("scfReadInterPoll") Then
  202. scfModifyInterPoll = 2
  203. Exit Function
  204. End If
  205. 'Dim c As DWbemClassObject
  206. Dim c As ISWbemObject
  207. Dim bigpath As String
  208. bigpath = "SMS_SCI_Component.FileType=2,ItemName=""SMS_SITE_COMPONENT_MANAGER|" & UCase(frmMain.txtServer.text) & """,ItemType=""Component"",SiteCode=""" & UCase(frmMain.txtSitecode.text) & """"
  209. 'wsoServices.GetObject bigpath, 0, wcoContext, c, Nothing
  210. Set c = wsoServices.Get(bigpath, , wcoContext)
  211. If CheckError(Err.Number, n, "GetObject " & bigpath) Then Exit Function
  212. Dim vary As Variant
  213. 'c.Get "Props", 0, vary, 0, 0 'give up the props, home-boy!
  214. vary = c.Properties_("Props").Value
  215. If CheckError(Err.Number, n, "Get Props") Then Exit Function
  216. Dim i As Integer
  217. Dim v As Variant
  218. For i = LBound(vary) To LBound(vary)
  219. 'vary(i).Get "PropertyName", 0, v, 0, 0
  220. 'If CheckError(Err.Number, n, "Get PropertyName") Then Exit Function
  221. If CStr(vary(i).PropertyName) = "Inter-Poll Delay Time" Then
  222. 'vary(i).Put "Value", 0, CVar(lInterpoll + 1), 0
  223. vary(i).Value = CVar(lInterpoll + 1)
  224. If CheckError(Err.Number, n, "Put Value") Then Exit Function
  225. 'c.Put "Props", 0, vary, 0
  226. c.Props = vary
  227. If CheckError(Err.Number, n, "Put Props") Then Exit Function
  228. 'wsoServices.PutInstance c, 0, wcoContext, Nothing
  229. '*** NO CONTEXT *** THIS MIGHT BE A PROBLEM
  230. c.Put_
  231. If CheckError(Err.Number, n, "SCI PutInstance") Then Exit Function
  232. 'this is a temp fix, till the bug is fixed.
  233. Dim m As Integer
  234. m = MsgBox("As of build 1024, the objectpath for the SMS_SiteControlFile:Commit Method is case sensitive. {Bug 23049}" & vbCrLf & _
  235. "If you want to test to see if this bug has been fixed, Click 'Yes'. Otherwise click 'No'. " & vbCrLf, vbYesNo, "Select Case")
  236. Select Case m
  237. Case vbYes
  238. 'wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & frmMain.txtSitecode.text & """", "Commit", 0, wcoContext, Nothing, Nothing, Nothing
  239. wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & frmMain.txtSitecode.text & """", "Commit", , , wcoContext
  240. n.text = n.text & " {Lower Case}"
  241. Case vbNo
  242. 'wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & UCase(frmMain.txtSitecode.text) & """", "Commit", 0, wcoContext, Nothing, Nothing, Nothing
  243. wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & UCase(frmMain.txtSitecode.text) & """", "Commit", , , wcoContext
  244. n.text = n.text & " {Upper Case - Workaround}"
  245. End Select
  246. ''rem'd this out till bug above gets fixed
  247. ''wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & frmMain.txtSitecode.text & """", "Commit", 0, wcoContext, Nothing, Nothing, Nothing
  248. 'wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=2,Sitecode=""" & frmMain.txtSitecode.text & """", "Commit",,,wcocontext
  249. If CheckError(Err.Number, n, "ExecMethod Commit") Then Exit Function
  250. scfModifyInterPoll = 1
  251. Exit Function
  252. End If
  253. Next i
  254. n.Tag = n.Tag & "Inter-Poll Delay Time property could not be found."
  255. scfModifyInterPoll = 2
  256. End Function
  257. Private Function scfWait(n As Node) As Integer
  258. On Error Resume Next
  259. If Not frmTest.AllOfThesePassed("scfModifyInterPoll") Then
  260. scfWait = 2
  261. Exit Function
  262. End If
  263. Dim try As Integer
  264. try = 1
  265. 'Dim c As DWbemClassObject
  266. Dim c As ISWbemObject
  267. Dim bigpath As String
  268. Dim vary As Variant
  269. Dim i As Integer
  270. Dim v As Variant
  271. Dim t As Single
  272. bigpath = "SMS_SCI_Component.FileType=1,ItemName=""SMS_SITE_COMPONENT_MANAGER|" & UCase(frmMain.txtServer.text) & """,ItemType=""Component"",SiteCode=""" & UCase(frmMain.txtSitecode.text) & """"
  273. Do While try < 18
  274. Set c = Nothing
  275. n.text = "Verify Changes: Attempt " & Trim(Str(try))
  276. 'wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & frmMain.txtSitecode.text & """", "Refresh", 0, wcoContext, Nothing, Nothing, Nothing
  277. wsoServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & frmMain.txtSitecode.text & """", "Refresh", , , wcoContext
  278. If CheckError(Err.Number, n, "ExecMethod Refresh") Then Exit Function
  279. 'wsoServices.GetObject bigpath, 0, wcoContext, c, Nothing
  280. Set c = wsoServices.Get(bigpath, , wcoContext)
  281. If CheckError(Err.Number, n, "Getobject " & bigpath) Then Exit Function
  282. 'c.Get "Props", 0, vary, 0, 0 'give up the props, home-boy!
  283. vary = c.Properties_("Props").Value
  284. If CheckError(Err.Number, n, "Get Props") Then Exit Function
  285. For i = LBound(vary) To LBound(vary)
  286. 'vary(i).Get "PropertyName", 0, v, 0, 0
  287. 'If CheckError(Err.Number, n, "Get PropertyName") Then Exit Function
  288. If CStr(vary(i).PropertyName) = "Inter-Poll Delay Time" Then
  289. 'vary(i).Get "Value", 0, v, 0, 0
  290. If CLng(vary(i).Value) = lInterpoll + 1 Then
  291. scfWait = 1
  292. n.text = n.text & " passed."
  293. Exit Function
  294. End If
  295. End If
  296. Next i
  297. t = Timer
  298. n.text = "Verify Changes: Attempt " & Trim(Str(try)) & " failed. Pausing..."
  299. Do While Timer < t + 2
  300. DoEvents
  301. Loop
  302. try = try + 1
  303. Loop
  304. n.text = "Verify Changes: Timed out. All attempts failed."
  305. scfWait = 0
  306. End Function
  307. Private Function scfWaitBug(n As Node) As Integer
  308. Dim m As Integer
  309. m = MsgBox("As of build 1004, changes to the master site control file cannot be verified programmatically. (bug 21658)" & vbCrLf & _
  310. "Please check the Sms\inboxes\sitectrl.box\sitectrl.ct0 file to verify that the value for the ""Inter-Poll"" delay time" & vbCrLf & _
  311. "has been set to " & Trim(Str(lInterpoll + 1)) & ". It may take several minutes for sms to digest the changes" & vbCrLf & _
  312. "and modify the master site control file. Press Yes if the changes were successful. Press No if the changes" & vbCrLf & _
  313. "were not made. Press Cancel to skip.", vbYesNoCancel, "Verify Changes")
  314. Select Case m
  315. Case vbYes
  316. scfWaitBug = 1
  317. Case vbNo
  318. scfWaitBug = 0
  319. Case vbCancel
  320. scfWaitBug = 2
  321. Case Else
  322. scfWaitBug = 3
  323. End Select
  324. End Function