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.

1038 lines
42 KiB

  1. <% '==================================================
  2. ' Microsoft Server Appliance
  3. '
  4. ' Serves task wizard/propsheet
  5. '
  6. ' Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.
  7. '================================================== %>
  8. <!-- #include file="sh_page.asp" -->
  9. <% ' Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.
  10. 'Task module-level variables
  11. Dim mstrPageName ' used as page identifier, e.g., "Intro"
  12. Dim mstrTaskTitle ' e.g., "Add User"
  13. Dim mstrPageTitle ' e.g., "Username and Password"
  14. Dim mstrTaskType ' "wizard", "prop"
  15. Dim mstrPageType ' "intro", "standard", "finish"
  16. Dim mstrMethod ' "BACK", "NEXT", "FINISH", etc
  17. Dim mstrReturnURL ' URL to return to after ending task
  18. Dim mstrFrmwrkFormStrings ' framework form values, list of strings to exclude
  19. Dim mstrIconPath ' image for upper right header
  20. Dim mstrPanelPath ' image for left panel of intro and finish pg
  21. Dim mblnCancelDirect ' browser returns directly to ReturnURL
  22. Dim mblnFinishDirect ' browser returns directly to ReturnURL
  23. Dim mintElementIndex ' index of embedded wizard page (0 - n, -1 = no extensions)
  24. Dim mintElementCount ' number of embedded pages in wizard
  25. Dim mstrErrMsg ' used by SetErrMsg and GetErrMsg
  26. Dim mstrAsyncTaskName ' Task EXE name - empty if task is synchronous
  27. Dim intCaptionIDTask
  28. On Error Resume Next
  29. Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
  30. strSourceName = "sakitmsg.dll"
  31. if Err.number <> 0 then
  32. Response.Write "Error in localizing the web content "
  33. Response.End
  34. end if
  35. '-----------------------------------------------------
  36. 'START of localization content
  37. Dim L_BACK_BUTTON
  38. Dim L_BACKIE_BUTTON
  39. Dim L_NEXT_BUTTON
  40. Dim L_NEXTIE_BUTTON
  41. Dim L_FINISH_BUTTON
  42. Dim L_OK_BUTTON
  43. Dim L_CANCEL_BUTTON
  44. Dim L_BACK_ACCESSKEY
  45. Dim L_NEXT_ACCESSKEY
  46. Dim L_FINISH_ACCESSKEY
  47. L_BACK_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001C",varReplacementStrings)
  48. L_BACKIE_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001D",varReplacementStrings)
  49. L_NEXT_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001E",varReplacementStrings)
  50. L_NEXTIE_BUTTON = objLocMgr.GetString(strSourceName, "&H4001001F",varReplacementStrings)
  51. L_FINISH_BUTTON = objLocMgr.GetString(strSourceName, "&H40010020",varReplacementStrings)
  52. L_OK_BUTTON = objLocMgr.GetString(strSourceName, "&H40010021",varReplacementStrings)
  53. L_CANCEL_BUTTON = objLocMgr.GetString(strSourceName, "&H40010022",varReplacementStrings)
  54. L_BACK_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H40010039",varReplacementStrings)
  55. L_NEXT_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003A",varReplacementStrings)
  56. L_FINISH_ACCESSKEY = objLocMgr.GetString(strSourceName, "&H4001003B",varReplacementStrings)
  57. 'End of localization content
  58. '-----------------------------------------------------
  59. 'Task Constants
  60. Const PROPERTY_TASK_NICE_NAME = "TaskNiceName"
  61. Const PROPERTY_TASK_URL = "TaskURL"
  62. Const WBEM_E_PROVIDER_NOT_CAPABLE = "&H80041024"
  63. Const WIZARD_TASK = "wizard"
  64. Const PROPSHEET_TASK = "prop"
  65. Const BODY_PAGE = "standard"
  66. Const INTRO_PAGE = "intro"
  67. Const FINISH_PAGE = "finish"
  68. Const BACK_METHOD = "BACK"
  69. Const NEXT_METHOD = "NEXT"
  70. Const FINISH_METHOD = "FINISH"
  71. Const CANCEL_METHOD = "CANCEL"
  72. 'Get standard task values and initialize
  73. mstrMethod = Request.Form("Method")
  74. mstrPageName = Request("PageName")
  75. mstrReturnURL = Request("ReturnURL")
  76. mintElementIndex = -1 ' set later in ServeWizardEmbeds()
  77. mintElementCount = Request.Form("EmbedPageCount") ' get previous value, if any
  78. If mintElementCount="" Then
  79. mintElementCount=0
  80. End If
  81. mstrFrmwrkFormStrings = "!method!pagename!pagetype!tasktype!returnurl!embedpageindex!embedpagecount!commonvalues!canceldirect!finishdirect!embedvalues0!embedvalues1!embedvalues2!embedvalues3!embedvalues4!"
  82. mblnCancelDirect = True
  83. mblnFinishDirect = False
  84. Set objLocMgr = Server.CreateObject("ServerAppliance.LocalizationManager")
  85. 'Setup task page
  86. Select Case mstrPageName
  87. Case "shTaskFooter"
  88. ServeTaskFooterFrame()
  89. End Select
  90. '----------------------------------------------------------------------------
  91. '
  92. ' Function : AsyncTaskBusy
  93. '
  94. ' Synopsis : Determine if the async task is currently being executed
  95. '
  96. ' Arguments: TaskName(IN) - async task name
  97. '
  98. ' Returns : true/false
  99. '
  100. '----------------------------------------------------------------------------
  101. Function AsyncTaskBusy(TaskName)
  102. Dim objTask
  103. On Error Resume Next
  104. Set objTask = GetObject("WINMGMTS:{impersonationLevel=impersonate}!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Task.TaskName=" & Chr(34) & TaskName & Chr(34) )
  105. If Not objTask.IsAvailable Then
  106. AsyncTaskBusy = True
  107. Else
  108. AsyncTaskBusy = False
  109. End If
  110. Set objTask = Nothing
  111. End Function
  112. '----------------------------------------------------------------------------
  113. '
  114. ' Function : SetErrMsg
  115. '
  116. ' Synopsis : Sets framework error message string
  117. '
  118. ' Arguments: Message(IN) - error message text
  119. '
  120. ' Returns : Nothing
  121. '
  122. '----------------------------------------------------------------------------
  123. Function SetErrMsg(Message)
  124. On Error Resume Next
  125. mstrErrMsg = Message
  126. End Function
  127. '----------------------------------------------------------------------------
  128. '
  129. ' Function : GetErrMsg
  130. '
  131. ' Synopsis : Gets the current framework error message string
  132. '
  133. ' Arguments: None
  134. '
  135. ' Returns : None
  136. '
  137. '----------------------------------------------------------------------------
  138. Function GetErrMsg()
  139. On Error Resume Next
  140. GetErrMsg = mstrErrMsg
  141. End Function
  142. '----------------------------------------------------------------------------
  143. '
  144. ' Function : ServeFormValues
  145. '
  146. ' Synopsis : Serves service specific form values while navigating wizard
  147. ' pages
  148. '
  149. ' Arguments: None
  150. '
  151. ' Returns : None
  152. '
  153. '----------------------------------------------------------------------------
  154. Function ServeFormValues()
  155. Dim objItem
  156. Dim strNewCommonData
  157. Dim strOldCommonData
  158. Dim strOldEmbData()
  159. Dim strNewEmbData()
  160. Dim intOldEmbIndex
  161. Dim intPos1
  162. Dim intPos2
  163. Dim strName
  164. Dim strValue
  165. Dim strNameD
  166. Dim strValueD
  167. Dim arrName()
  168. Dim arrValue()
  169. Dim i, j
  170. Dim rc
  171. On Error Resume Next
  172. strNameD = ";;"
  173. strValueD = ";"
  174. ReDim strOldEmbData(mintElementCount)
  175. ReDim strNewEmbData(mintElementCount)
  176. ' get data from post
  177. strOldCommonData = Request.Form("CommonValues") ' data from host pages
  178. For i = 0 To mintElementCount
  179. strOldEmbData(i) = Request.Form("EmbedValues" & i) ' data from embedded pages
  180. Next
  181. intOldEmbIndex = CInt(Request.Form("EmbedPageIndex"))
  182. For i = 0 To mintElementCount ' get previously saved Embed values
  183. If i <> intOldEmbIndex Then
  184. strNewEmbData(i) = strOldEmbData(i)
  185. End If
  186. Next
  187. For Each objItem in Request.Form 'loop through items in posted form
  188. strName = LCase(objItem)
  189. strName = Replace(strName, strValueD, "")
  190. strValue = Trim(Request.Form(objItem))
  191. strValue = Replace(strValue, strValueD, "")
  192. If strValue = "" Then strValue = " "
  193. If InStr(mstrFrmwrkFormStrings, "!" & strName & "!") = 0 Then
  194. ' host page data
  195. If strOldCommonData = "" Then
  196. ' in intro page
  197. strNewCommonData = strNewCommonData & strNameD & strName & strValueD & strValue
  198. ElseIf InStr(LCase(strOldCommonData), strNameD & strName & strValueD) <> 0 Then
  199. ' in body page
  200. strNewCommonData = strNewCommonData & strNameD & strName & strValueD & strValue
  201. ElseIf intOldEmbIndex <> -1 And Request.Form("PageName") = "TaskExtension" Then
  202. 'extension page - update data for current page
  203. If InStr(LCase(strOldCommonData), strNameD & strName & strValueD) = 0 Then
  204. strNewEmbData(intOldEmbIndex) = strNewEmbData(intOldEmbIndex) & strNameD & strName & strValueD & strValue
  205. End If
  206. End If
  207. End If
  208. Next
  209. Response.Write "<input name=" & chr(34) & "EmbedPageIndex" & Chr(34) & " type=hidden value=" & Chr(34) & mintElementIndex & Chr(34) & ">" & vbCrLf
  210. Response.Write "<input name=" & chr(34) & "EmbedPageCount" & Chr(34) & " type=hidden value=" & Chr(34) & mintElementCount & Chr(34) & ">" & vbCrLf
  211. Response.Write "<input name=" & chr(34) & "CommonValues" & Chr(34) & " type=hidden value=" & Chr(34) & Server.HTMLEncode(strNewCommonData) & Chr(34) & ">" & vbCrLf
  212. For i = 0 To mintElementCount-1
  213. Response.Write "<input name=" & chr(34) & "EmbedValues" & i & Chr(34) & " type=hidden value=" & Chr(34) & strNewEmbData(i) & Chr(34) & ">" & vbCrLf
  214. If mstrPageType="finish" Then ' serve out embed values discretely in Finish page
  215. If UnpackData(strNewEmbData(i), arrName, arrValue, strNameD, strValueD) Then
  216. For j = 0 To UBound(arrName)
  217. Response.Write "<input name=" & chr(34) & arrName(j) & Chr(34) & " type=hidden value=" & Chr(34) & arrValue(j) & Chr(34) & ">" & vbCrLf
  218. Next
  219. End If
  220. End If
  221. Next
  222. If mstrPageName = "TaskExtension" Then
  223. If UnpackData(strNewCommonData, arrName, arrValue, strNameD, strValueD) Then ' serve out common data as discreet form values
  224. For i = 0 To UBound(arrName)
  225. Response.Write "<input name=" & chr(34) & arrName(i) & Chr(34) & " type=hidden value=" & Chr(34) & arrValue(i) & Chr(34) & ">" & vbCrLf
  226. Next
  227. End If
  228. End If
  229. End Function
  230. '----------------------------------------------------------------------------
  231. '
  232. ' Function : UnPackData
  233. '
  234. ' Synopsis : Unpacks service specific form values from one string into
  235. ' individual <name, value> pairs
  236. '
  237. ' Arguments: InputStrings(IN) - input form variable (which contains all
  238. ' <form, value> pairs as one string
  239. ' arrName(OUT) - on output contains all service form value names
  240. ' arrValue(OUT) - on output contains all service form value values
  241. ' strNameD(IN) - delimiter between names in InputString
  242. ' strValueD(IN) - delimiter between values in InputString
  243. '
  244. ' Returns : None
  245. '
  246. '----------------------------------------------------------------------------
  247. Function UnPackData(InputString, arrName, arrValue, strNameD, strValueD)
  248. Dim intPos1, intPos2
  249. Dim intIndex
  250. On Error Resume Next
  251. InputString = LTrim(InputString)
  252. If InputString = "" Then
  253. UnPackData = False
  254. Exit Function
  255. End If
  256. If Left(InputString, 2) = strNameD Then
  257. InputString = Right(InputString, Len(InputString) - 2)
  258. End If
  259. intIndex = 0
  260. intPos1 = InStr(InputString, strValueD)
  261. intPos2 = -1
  262. Do While intPos1 <> 0
  263. ReDim Preserve arrName(intIndex)
  264. ReDim Preserve arrValue(intIndex)
  265. arrName(intIndex) = Trim(Mid(InputString, intPos2 + 2, intPos1 - intPos2 - 2))
  266. intPos2 = InStr(intPos1, InputString, strNameD)
  267. If intPos2 = 0 Then
  268. intPos2 = Len(InputString) + 1 'assumes no end delimiter
  269. End If
  270. arrValue(intIndex) = Trim(Mid(InputString, intPos1 + 1, intPos2 - intPos1 - 1))
  271. If intPos2 + 1 < Len(InputString) Then
  272. intPos1 = InStr(intPos2 + 2, InputString, strValueD)
  273. Else
  274. Exit Do
  275. End If
  276. intIndex = intIndex + 1
  277. Loop
  278. UnPackData = True
  279. End Function
  280. '----------------------------------------------------------------------------
  281. '
  282. ' Function : ServeTaskHeader
  283. '
  284. ' Synopsis : Serve the task header based on page type
  285. ' Note: Uses module-level variables listed below. These values
  286. ' are set for each task and page as needed.
  287. ' mstrTaskType - "wizard", "prop"
  288. ' mstrPageType - "intro", "finish", "standard"
  289. ' mintElementIndex - index of wizard extension page, (0 - n)
  290. ' mintElementCount - count of extension pages
  291. ' mblnFinishDirect - finish button behavior
  292. ' mblnCancelDirect - cancel button behavior
  293. '
  294. ' Arguments: None
  295. '
  296. ' Returns : None
  297. '
  298. '----------------------------------------------------------------------------
  299. Function ServeTaskHeader()
  300. Dim objItem
  301. On Error Resume Next
  302. Response.Buffer = True
  303. %>
  304. <html LANG="en">
  305. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  306. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  307. <head>
  308. <title><% =mstrTaskTitle %></title>
  309. <script language=JavaScript src="../sh_page.js"></script>
  310. <script language=JavaScript>
  311. var VirtualRoot = '<%=m_VirtualRoot%>';
  312. </script>
  313. <script language=JavaScript src="../sh_task.js"></script>
  314. <link rel="STYLESHEET" type="text/css" href="<%=m_VirtualRoot%>sh_task.css">
  315. </head>
  316. <BODY marginWidth="0" marginHeight="0" onload="PageInit();" topmargin="0" leftmargin="0" rightmargin="0" onDragDrop="return false;" oncontextmenu="return false;">
  317. <FORM name="frmTask" onSubmit="return Next();" action="<% =GetScriptFileName %>" method="POST">
  318. <INPUT name="PageName" type="hidden" value="<% =mstrPageName %>">
  319. <INPUT name="Method" type="hidden" value="<% =mstrMethod %>">
  320. <INPUT name="ReturnURL" type="hidden" value="<% =mstrReturnURL %>">
  321. <INPUT name="TaskType" type="hidden" value="<% =mstrTaskType %>">
  322. <INPUT name="PageType" type="hidden" value="<% =mstrPageType %>">
  323. <INPUT name="FinishDirect" type="hidden" value="<% =mblnFinishDirect %>">
  324. <INPUT name="CancelDirect" type="hidden" value="<% =mblnCancelDirect %>">
  325. <%
  326. ' conditionally serve hidden form elements from extended
  327. ' task page
  328. if mstrTaskType="wizard" then
  329. ServeFormValues()
  330. end if
  331. %>
  332. <% If( (mstrTaskType="wizard") AND (mstrPageType="intro" OR mstrPageType="finish")) Then %>
  333. <TABLE width=100% height=101% border=0 cellspacing=0 cellpadding=0 ID=TASKTABLE>
  334. <TR valign=TOP style="background-color:#FFFFFF">
  335. <TD width="10%" align="right" valign=TOP style="width:130px; background-color: #313163" rowspan="2">
  336. <IMG width=130 border=0 src="<% =mstrPanelPath %>" >
  337. </td>
  338. <TD width=18 valign=TOP style="background-color: white;" rowspan="2">
  339. &nbsp;&nbsp;
  340. </td>
  341. <TD valign=TOP style="background-color: white;" rowspan="2">
  342. <span class="TASKTITLE"><% =mstrTaskTitle %></span>
  343. <BR><BR>
  344. <% Else %>
  345. <TABLE width=100% border=0 height="88%" cellspacing=0 cellpadding=0 ID=TASKTABLE >
  346. <TR valign=TOP height="10%" style="background-color:#FFFFFF">
  347. <TD width=3% height="10%" valign=TOP>
  348. &nbsp;&nbsp;
  349. </TD>
  350. <TD valign=TOP>
  351. <span CLASS="TASKTITLE"><%=mstrTaskTitle %></span><BR>
  352. &nbsp;&nbsp;&nbsp;<span class="PAGETITLE"><% =mstrPageTitle %></span>
  353. </TD>
  354. <TD align="right" valign=TOP bgcolor="#FFFFFF">
  355. <IMG height=64 width=64 border=0 src="<% =mstrIconPath %>">
  356. </TD>
  357. </TR>
  358. <TR height="80%" valign=TOP>
  359. <TD width=26px height=64 valign=TOP>
  360. &nbsp;&nbsp;
  361. </TD>
  362. <TD valign="top" height="70%" colspan=2>
  363. <BR>
  364. <% End IF%>
  365. <%
  366. ServeTaskHeader = True
  367. End Function
  368. '----------------------------------------------------------------------------
  369. '
  370. ' Function : ServeTaskFooter
  371. '
  372. ' Synopsis : Serve the task footer (navigation buttons & error div)
  373. ' Note: The function relies on the following module-level variables:
  374. ' mstrTaskType - prop wizard
  375. ' mstrPageType - standard intro finish failure
  376. '
  377. ' Arguments: None
  378. '
  379. ' Returns : None
  380. '
  381. '----------------------------------------------------------------------------
  382. Function ServeTaskFooter()
  383. On Error Resume Next
  384. dim ErrMessage
  385. If GetErrMsg <> "" Then
  386. ErrMessage = "<img src=" & m_VirtualRoot & "images/critical_g.gif border=0>&nbsp;&nbsp;" & GetErrMsg
  387. SetErrMsg ""
  388. else
  389. ErrMessage =""
  390. End If
  391. %>
  392. </TD>
  393. </TR>
  394. <%
  395. If( (mstrPageType<>"intro") AND (mstrPageType<>"finish") ) Then
  396. If (IsIE()) Then
  397. %>
  398. <Table>
  399. <TR>
  400. <TD>&nbsp;</TD>
  401. <TD ><DIV name="divErrMsg" ID="divErrMsg" class="ErrMsg"><%=ErrMessage%></DIV></TD>
  402. </TR>
  403. </Table>
  404. <% End If %>
  405. <% End If %>
  406. </td></tr>
  407. </table>
  408. <% If Not IsIE() Then %>
  409. <layer name="layErrMsg" class="ErrMsg"><%=ErrMessage%></layer>
  410. <% End If %>
  411. <%
  412. Response.Write "</form></BODY></HTML>"
  413. End Function
  414. '----------------------------------------------------------------------------
  415. '
  416. ' Function : ServeFailurePage
  417. '
  418. ' Synopsis : Serve the page which redirects the browser to the err_view.asp
  419. ' failure page
  420. '
  421. ' Arguments: Message(IN) - message to be displayed by err_view.asp
  422. ' intTab(IN) - Tab to be highlighted by err_view.asp
  423. '
  424. ' Returns : None
  425. '
  426. '----------------------------------------------------------------------------
  427. Function ServeFailurePage(Message, intTab)
  428. On Error Resume Next
  429. Dim strURL
  430. If InStr(mstrReturnURL, "?") = 0 Then
  431. strURL = mstrReturnURL & "?R="
  432. else
  433. strURL = mstrReturnURL & "&R="
  434. end if
  435. %>
  436. <html>
  437. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  438. <head>
  439. <SCRIPT language=JavaScript>
  440. function Redirect() {
  441. top.location = "<%=getVirtualDirectory()%>" + "util/err_view.asp?Tab=<%=intTab%>&Message=<% =server.urlencode(Message) %>&ReturnURL=<% =strURL%>" + Math.random();
  442. }
  443. </SCRIPT>
  444. </head>
  445. <body onLoad="Redirect();" bgcolor="#000000">
  446. &nbsp;
  447. </body>
  448. </html>
  449. <%
  450. Response.End
  451. End Function
  452. '----------------------------------------------------------------------------
  453. '
  454. ' Function : ServeClose
  455. '
  456. ' Synopsis : Redirect user to the page from which the wizard was launched
  457. '
  458. ' Arguments: None
  459. '
  460. ' Returns : None
  461. '
  462. '----------------------------------------------------------------------------
  463. Sub ServeClose
  464. On Error Resume Next
  465. %>
  466. <html>
  467. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  468. <head>
  469. <SCRIPT language=JavaScript>
  470. function Redirect()
  471. {
  472. top.location='<%=EscapeQuotes(mstrReturnURL)%>';
  473. }
  474. </SCRIPT>
  475. </head>
  476. <body onLoad="Redirect();" bgcolor="Silver">
  477. &nbsp;
  478. </body>
  479. </html>
  480. <%
  481. End Sub
  482. '----------------------------------------------------------------------------
  483. '
  484. ' Function : ServePropEmbeds
  485. '
  486. ' Synopsis : Serve the embedded property pages
  487. '
  488. ' Arguments: None
  489. '
  490. ' Returns : None
  491. '
  492. '----------------------------------------------------------------------------
  493. Function ServePropEmbeds()
  494. Dim objElementCol
  495. Dim objElement
  496. Dim rc
  497. On Error Resume Next
  498. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  499. For Each objElement in objElementCol
  500. rc = GetEmbedHTML(objElement, 0)
  501. Next
  502. Set objElementCol = Nothing
  503. ServePropEmbeds = True
  504. End Function
  505. '----------------------------------------------------------------------------
  506. '
  507. ' Function : ServeWizardEmbeds
  508. '
  509. ' Synopsis : Handles navigation through wizard extension pages.
  510. ' Note: uses module-level value mstrMethod
  511. '
  512. ' Arguments: TopPage(IN) - the page just before the first embedded page
  513. ' in the wizard.
  514. ' BottomPage(IN) - the page just after the last embedded page
  515. ' in the wizard.
  516. '
  517. ' Returns : Returns true or false if HTML is output. Writes wizard HTML
  518. ' to the client.
  519. ' mintElementIndex is set here after getting the initial value
  520. '
  521. '----------------------------------------------------------------------------
  522. Function ServeWizardEmbeds(TopPage, BottomPage)
  523. Dim booServedPage
  524. Dim objElementCol
  525. Dim objElement
  526. Dim arrElementID()
  527. Dim intOrigIndex
  528. Dim i
  529. On Error Resume Next
  530. mintElementIndex = CInt(Request.Form("EmbedPageIndex"))
  531. Response.Buffer = True
  532. booServedPage = False
  533. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  534. mintElementCount = objElementCol.Count
  535. ReDim arrElementID(mintElementCount)
  536. i = 0
  537. For Each objElement in objElementCol
  538. arrElementID(i) = objElement.GetProperty("ElementID")
  539. i = i + 1
  540. Next
  541. If LCase(mstrPageName) = LCase(TopPage) Then
  542. ' entering start of extension (method=NEXT, currentpage=TopPage)
  543. For mintElementIndex = 0 to UBound(arrElementID)-1
  544. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  545. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  546. booServedPage = True
  547. Exit For
  548. End If
  549. Next
  550. If Not booServedPage Then
  551. ServePage(BottomPage)
  552. End If
  553. ElseIf mstrPageName = BottomPage Then
  554. ' entering end of extension (method=BACK, currentpage=BottomPage)
  555. For mintElementIndex = UBound(arrElementID)-1 to 0 Step -1
  556. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  557. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  558. booServedPage = True
  559. Exit For
  560. End If
  561. Next
  562. If Not booServedPage Then
  563. ServePage(TopPage)
  564. End If
  565. Else
  566. 'Inside the extension pages (method=NEXT | BACK, currentpage="ExtensionPage" )
  567. intOrigIndex = mintElementIndex
  568. If mstrMethod = "NEXT" Then
  569. For mintElementIndex = intOrigIndex + 1 to UBound(arrElementID)-1
  570. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  571. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  572. booServedPage = True
  573. Exit For
  574. End If
  575. Next
  576. If Not booServedPage Then
  577. ServePage(BottomPage)
  578. End If
  579. ElseIf mstrMethod = "BACK" Then
  580. For mintElementIndex = intOrigIndex - 1 To 0 Step -1
  581. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  582. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  583. booServedPage = True
  584. Exit For
  585. End If
  586. Next
  587. If Not booServedPage Then
  588. ServePage(TopPage)
  589. End If
  590. End If
  591. End If
  592. Set objElementCol = Nothing
  593. Set objElement = Nothing
  594. End Function
  595. '----------------------------------------------------------------------------
  596. '
  597. ' Function : ServeEmbedWizardPage
  598. '
  599. ' Synopsis : Serve the embedded wizard pages. Handles the actual building of
  600. ' the page
  601. '
  602. ' Arguments: Element(IN) - the element obj for the wizard page to be
  603. ' served.
  604. ' ElementIndex(IN) - element index
  605. '
  606. ' Returns : None
  607. '
  608. '----------------------------------------------------------------------------
  609. Function ServeEmbedWizardPage(Element, ElementIndex)
  610. On Error Resume Next
  611. 'set task framework variables
  612. mstrPageName = "TaskExtension"
  613. mstrPageType = "standard"
  614. mstrTaskType = "wizard"
  615. intCaptionIDTask = "&H" & Element.GetProperty("CaptionRID")
  616. strSourceName = ""
  617. strSourceName = Element.GetProperty ("Source")
  618. Err.Clear
  619. If strSourceName = "" Then
  620. strSourceName = "svrapp"
  621. End If
  622. Err.Clear
  623. mstrPageTitle = objLocMgr.GetString(strSourceName, intCaptionIDTask, varReplacementStrings)
  624. If Err <> 0 Then
  625. Err.Clear
  626. mstrPageTitle = ""
  627. End If
  628. ServeTaskHeader
  629. If GetEmbedHTML(Element, 0) Then
  630. ServeTaskFooter
  631. ServeEmbedWizardPage = True
  632. Else
  633. ServeEmbedWizardPage = False
  634. Response.Clear
  635. End If
  636. End Function
  637. '----------------------------------------------------------------------------
  638. '
  639. ' Function : ExecuteTask
  640. '
  641. ' Synopsis : Calls Microsoft_SA_Task object by name
  642. '
  643. ' Arguments: TaskName(IN) - name of task to execute.
  644. ' TaskContext(IN) - empty task parameters object. Parameters in the
  645. ' form of hidden form values are added to this
  646. ' object before the task is executed.
  647. ' also mstrAsyncTaskName: if not empty, call task asynchronously
  648. '
  649. ' Returns : HRESULT from ExecuteTask, or
  650. ' 1 - TaskContext instantiation failed
  651. ' 2 - AppSrvcs instantiation failed
  652. ' 3 - AppSrvcs init failed
  653. ' TaskContext: populated ITaskContext
  654. '
  655. '----------------------------------------------------------------------------
  656. Function ExecuteTask(TaskName, TaskContext)
  657. Dim objAS
  658. Dim objTaskContext
  659. Dim objValue
  660. Dim objElementCol
  661. Dim objElement
  662. Dim varValue
  663. Dim strName
  664. Dim arrName
  665. Dim arrValue
  666. Dim rc
  667. Dim i
  668. On Error Resume Next
  669. Set objTaskContext = Server.CreateObject("Taskctx.TaskContext")
  670. If Err <> 0 Then
  671. ExecuteTask = 1
  672. Else
  673. Set objAS = Server.CreateObject("Appsrvcs.ApplianceServices")
  674. If Err <> 0 Then
  675. ExecuteTask = 2
  676. Else
  677. objAS.Initialize()
  678. If Err = 0 Then
  679. For Each objValue in Request.Form
  680. strName = objValue
  681. If InStr(mstrFrmwrkFormStrings, "!" & strName & "!") = 0 Then 'set normal form value data
  682. varValue = Request.Form(objValue)
  683. objTaskContext.SetParameter strName, varValue
  684. End If
  685. Next
  686. objTaskContext.SetParameter PROPERTY_TASK_NICE_NAME, mstrTaskTitle
  687. objTaskContext.SetParameter PROPERTY_TASK_URL, "/" & GetScriptPath()
  688. Err.Clear
  689. If mstrAsyncTaskName <> "" Then
  690. rc = objAS.ExecuteTaskAsync(TaskName, objTaskContext)
  691. If rc = WBEM_E_PROVIDER_NOT_CAPABLE Then
  692. '
  693. 'This indicates that the async task is currently running
  694. '
  695. End If
  696. Else
  697. rc = objAS.ExecuteTask(TaskName, objTaskContext)
  698. End If
  699. ' check for and handle errors in embedded pages
  700. If rc <> 0 And mstrTaskType = "wizard" And mintElementCount > 0 Then
  701. mintElementCount = 0
  702. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  703. mintElementCount = objElementCol.Count
  704. mintElementIndex = 0
  705. For Each objElement in objElementCol
  706. If ServeEmbedWizardPage(objElement, mintElementIndex, rc) Then
  707. Err.Clear
  708. ExecuteTask = rc
  709. Else
  710. mintElementIndex = mintElementIndex + 1
  711. End If
  712. Next
  713. Set objElementCol = Nothing
  714. Set objElement = Nothing
  715. End If
  716. ExecuteTask = Err.Number
  717. Err.Clear
  718. Set TaskContext = objTaskContext
  719. objAS.Shutdown()
  720. Else
  721. ExecuteTask = 3
  722. End If
  723. End If
  724. End If
  725. Err.Clear
  726. Set objAS = Nothing
  727. Set objTaskContext = Nothing
  728. End Function
  729. '==================================================
  730. Function ServeTaskFooterFrame()
  731. On Error Resume Next
  732. %>
  733. <html>
  734. <!-- (c) 1999 Microsoft Corporation. All rights reserved.-->
  735. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  736. <head>
  737. <title>Footer</title>
  738. <link rel="STYLESHEET" type="text/css" href="<%=m_VirtualRoot%>sh_task.css">
  739. <script language=JavaScript>
  740. var VirtualRoot = '<%=m_VirtualRoot%>';
  741. </script>
  742. <script language=JavaScript src="<%=m_VirtualRoot%>sh_page.js"></script>
  743. <script language=JavaScript src="<%=m_VirtualRoot%>sh_task.js"></script>
  744. <script language=JavaScript>
  745. function Init() {
  746. var formTask;
  747. if (IsIE())
  748. formTask = top.frames[0].frmTask;
  749. else
  750. formTask = parent.main.document.forms["frmTask"];
  751. if ( (formTask) && (top.footer.PropertyPageButtons) && (top.footer.WizardButtons) ) {
  752. var strTaskType = formTask.TaskType.value;
  753. var strPageType = formTask.PageType.value;
  754. if (document.layers)
  755. document.captureEvents(Event.KEYPRESS)
  756. document.onkeypress = HandleKeyPress;
  757. switch (strTaskType) {
  758. case "<% =PROPSHEET_TASK %>":
  759. if (IsIE()) {
  760. top.footer.PropertyPageButtons.style.display = "";
  761. top.footer.WizardButtons.style.display = "none";
  762. var tblTaskP = parent.main.document.all("TASKTABLE");
  763. if (tblTaskP)
  764. tblTaskP.focus();
  765. }
  766. else {
  767. document.layers["PropertyPageButtons"].visibility = "show";
  768. document.layers["WizardButtons"].visibility = "hide";
  769. document.layers["WizardButtons_Finish"].visibility = "hide";
  770. }
  771. top.main.EnableCancel();
  772. top.main.EnableOK();
  773. switch (strPageType) {
  774. case "failure":
  775. document.frmFooter.butOK.style.display = "none";
  776. break;
  777. default:
  778. break;
  779. }
  780. break;
  781. case "<% =WIZARD_TASK %>":
  782. if (IsIE()) {
  783. top.footer.WizardButtons.style.display = "";
  784. top.footer.PropertyPageButtons.style.display = "none";
  785. var tblTaskW = parent.main.document.all("TASKTABLE");
  786. if (tblTaskW)
  787. tblTaskW.focus();
  788. }
  789. else {
  790. document.layers["PropertyPageButtons"].visibility = "hide";
  791. }
  792. top.main.EnableBack();
  793. top.main.EnableCancel();
  794. switch (strPageType) {
  795. case "<% =INTRO_PAGE %>":
  796. top.main.DisableBack();
  797. if (!IsIE()) {
  798. document.layers["WizardButtons_Finish"].visibility = "hide";
  799. document.layers["WizardButtons"].visibility = "show";
  800. }
  801. else
  802. top.main.EnableNext();
  803. break;
  804. case "<% =FINISH_PAGE %>":
  805. if (IsIE()) {
  806. top.footer.frmFooter.butNext.style.display = "none";
  807. top.footer.frmFooter.butFinish.style.display = "";
  808. }
  809. else {
  810. document.layers["WizardButtons_Finish"].visibility = "show";
  811. document.layers["WizardButtons"].visibility = "hide";
  812. }
  813. top.main.EnableFinish();
  814. break;
  815. default:
  816. if (IsIE()) {
  817. top.footer.frmFooter.butNext.style.display = "";
  818. top.footer.frmFooter.butFinish.style.display = "none";
  819. top.main.EnableNext();
  820. }
  821. else {
  822. document.layers["WizardButtons"].visibility = "show";
  823. document.layers["WizardButtons_Finish"].visibility = "hide";
  824. }
  825. break;
  826. }
  827. break;
  828. default:
  829. if (IsIE())
  830. PropertyPageButtons.style.display = "";
  831. break;
  832. }
  833. }
  834. else
  835. window.setTimeout('Init();',50);
  836. }
  837. </script>
  838. </head>
  839. <BODY onLoad="Init()" oncontextmenu="return false;" topmargin="0" leftmargin="0" rightmargin="0" onDragDrop="return false;" tabindex=-1>
  840. <% If Not IsIE() Then %>
  841. <layer ID="WizardButtons" name="WizardButtons" visibility="hide" z-Index="1" width=100%>
  842. <FORM name="frmFooter">
  843. <table width=100% cellspacing=10 cellpadding=0 border=0><tr><td width=95%></td>
  844. <td>
  845. <input name="butBack" class="NAVBUTTON" type="button" value="<% =L_BACK_BUTTON %>"
  846. onClick="if (parent.main.document.forms['frmTask']) parent.main.Back();">
  847. </td><td>
  848. <input name="butNext" class="NAVBUTTON" type="button" value="<% =L_NEXT_BUTTON %>"
  849. onClick="if (parent.main.document.forms['frmTask']) parent.main.Next();">
  850. </td><td>
  851. <input name="butCancelW" class="NAVBUTTON" type="button" value="<% =L_CANCEL_BUTTON %>"
  852. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();">
  853. </td></tr></table>
  854. </form>
  855. </layer>
  856. <layer ID="WizardButtons_Finish" visibility="hide" width=100%>
  857. <FORM name="frmFooter">
  858. <table width=100% cellspacing=10 cellpadding=0 border=0><tr><td width=95%></td>
  859. <td>
  860. <input name="butBack" class="NAVBUTTON" type="button" value="<% =L_BACK_BUTTON %>"
  861. onClick="if (parent.main.document.forms['frmTask']) parent.main.Back();">
  862. </td><td>
  863. <input name="butFinish" type="button" value="<% =L_FINISH_BUTTON %>" class="NAVBUTTON"
  864. onClick="if (parent.main.document.forms['frmTask']) parent.main.FinishShell();">
  865. </td><td>
  866. <input name="butCancelW" class="NAVBUTTON" type="button" value="<% =L_CANCEL_BUTTON %>"
  867. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();">
  868. </td></tr></table>
  869. </form>
  870. </layer>
  871. <layer ID="PropertyPageButtons" visibility="hide" width="100%">
  872. <FORM name="frmFooter">
  873. <table width=100% cellspacing=10 cellpadding=0 border=0>
  874. <tr><td width=90% ></td><td >
  875. <input type=button align=right value="<% =L_OK_BUTTON %>" alt="OK" name="butOK" class="NAVBUTTON"
  876. onClick="if (parent.main.document.forms['frmTask']) parent.main.Next();">
  877. &nbsp;
  878. </td><td>
  879. <input type="button" name="butCancelP" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  880. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();" class="NAVBUTTON">
  881. &nbsp;
  882. </td></tr></table>
  883. </form>
  884. </layer>
  885. <% Else %>
  886. <FORM name="frmFooter">
  887. <DIV ID="WizardButtons" style="display:none; position:absolute; top:10px; ">
  888. <table width=100% cellspacing=0 cellpadding=0>
  889. <tr> <td width=100% >&nbsp;</td>
  890. <td align="right" nowrap valign="middle">
  891. <button name="butBack" id="but_back01" class="NAVBUTTON" accesskey="<%=L_BACK_ACCESSKEY%>" alt="<% =L_BACK_BUTTON %>"
  892. onClick="if (parent.main.frmTask) parent.main.Back();"><% =L_BACKIE_BUTTON %></button>
  893. </td><td align="right" width="10" nowrap> &nbsp; </td>
  894. <td align="right" nowrap valign="middle">
  895. <button name="butNext" id="but_next01" class="NAVBUTTON" accesskey="<%=L_NEXT_ACCESSKEY%>" alt="<% =L_NEXT_BUTTON %>"
  896. onClick="if (parent.main.frmTask) parent.main.Next();"><% =L_NEXTIE_BUTTON %></button>
  897. </td>
  898. <td align="right" nowrap valign="middle">
  899. <button name="butFinish" id="but_finish01" class="NAVBUTTON" accesskey="<%=L_FINISH_ACCESSKEY%>" alt="<% =L_FINISH_BUTTON %>"
  900. style="display:none" onClick="if (parent.main.frmTask) parent.main.FinishShell();"><% =L_FINISH_BUTTON %></button>
  901. </td>
  902. <td align="right" width="10" nowrap> &nbsp; </td>
  903. <td align="right" nowrap valign="middle">
  904. <input type="button" name="butCancelW" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  905. style=""onClick="if (parent.main.frmTask) parent.main.Cancel();" class="NAVBUTTON">
  906. &nbsp;
  907. </td></tr></table>
  908. </div>
  909. <DIV ID="PropertyPageButtons" style="display:none; position:absolute; top:10px;">
  910. <table width=100% cellspacing=0 cellpadding=0><tr><td width=100% ></td><td nowrap>
  911. <input type=button align=right value="<% =L_OK_BUTTON %>" alt="OK" name="butOK" class="NAVBUTTON" onClick="if (parent.main.frmTask) parent.main.Next();">
  912. &nbsp;
  913. <input type="button" name="butCancelP" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  914. onClick="if (parent.main.frmTask) parent.main.Cancel();" class="NAVBUTTON">
  915. &nbsp;
  916. </td></tr></table>
  917. </div>
  918. </form>
  919. <% End If
  920. Response.Write "</BODY></HTML>"
  921. End Function
  922. %>