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.

1232 lines
46 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. '----------------------------------------------------------------------------
  86. '
  87. ' Function : AsyncTaskBusy
  88. '
  89. ' Synopsis : Determine if the async task is currently being executed
  90. '
  91. ' Arguments: TaskName(IN) - async task name
  92. '
  93. ' Returns : true/false
  94. '
  95. '----------------------------------------------------------------------------
  96. Function AsyncTaskBusy(TaskName)
  97. Dim objTask
  98. On Error Resume Next
  99. Set objTask = GetObject("WINMGMTS:{impersonationLevel=impersonate}!\\" & GetServerName & "\root\cimv2:Microsoft_SA_Task.TaskName=" & Chr(34) & TaskName & Chr(34) )
  100. If Not objTask.IsAvailable Then
  101. AsyncTaskBusy = True
  102. Else
  103. AsyncTaskBusy = False
  104. End If
  105. Set objTask = Nothing
  106. End Function
  107. '----------------------------------------------------------------------------
  108. '
  109. ' Function : SetErrMsg
  110. '
  111. ' Synopsis : Sets framework error message string
  112. '
  113. ' Arguments: Message(IN) - error message text
  114. '
  115. ' Returns : Nothing
  116. '
  117. '----------------------------------------------------------------------------
  118. Function SetErrMsg(Message)
  119. On Error Resume Next
  120. mstrErrMsg = Message
  121. End Function
  122. '----------------------------------------------------------------------------
  123. '
  124. ' Function : GetErrMsg
  125. '
  126. ' Synopsis : Gets the current framework error message string
  127. '
  128. ' Arguments: None
  129. '
  130. ' Returns : None
  131. '
  132. '----------------------------------------------------------------------------
  133. Function GetErrMsg()
  134. On Error Resume Next
  135. GetErrMsg = mstrErrMsg
  136. End Function
  137. '----------------------------------------------------------------------------
  138. '
  139. ' Function : ServeFormValues
  140. '
  141. ' Synopsis : Serves service specific form values while navigating wizard
  142. ' pages
  143. '
  144. ' Arguments: None
  145. '
  146. ' Returns : None
  147. '
  148. '----------------------------------------------------------------------------
  149. Function ServeFormValues()
  150. Dim objItem
  151. Dim strNewCommonData
  152. Dim strOldCommonData
  153. Dim strOldEmbData()
  154. Dim strNewEmbData()
  155. Dim intOldEmbIndex
  156. Dim intPos1
  157. Dim intPos2
  158. Dim strName
  159. Dim strValue
  160. Dim strNameD
  161. Dim strValueD
  162. Dim arrName()
  163. Dim arrValue()
  164. Dim i, j
  165. Dim rc
  166. On Error Resume Next
  167. strNameD = ";;"
  168. strValueD = ";"
  169. ReDim strOldEmbData(mintElementCount)
  170. ReDim strNewEmbData(mintElementCount)
  171. ' get data from post
  172. strOldCommonData = Request.Form("CommonValues") ' data from host pages
  173. For i = 0 To mintElementCount
  174. strOldEmbData(i) = Request.Form("EmbedValues" & i) ' data from embedded pages
  175. Next
  176. intOldEmbIndex = CInt(Request.Form("EmbedPageIndex"))
  177. For i = 0 To mintElementCount ' get previously saved Embed values
  178. If i <> intOldEmbIndex Then
  179. strNewEmbData(i) = strOldEmbData(i)
  180. End If
  181. Next
  182. For Each objItem in Request.Form 'loop through items in posted form
  183. strName = LCase(objItem)
  184. strName = Replace(strName, strValueD, "")
  185. strValue = Trim(Request.Form(objItem))
  186. strValue = Replace(strValue, strValueD, "")
  187. If strValue = "" Then strValue = " "
  188. If InStr(mstrFrmwrkFormStrings, "!" & strName & "!") = 0 Then
  189. ' host page data
  190. If strOldCommonData = "" Then
  191. ' in intro page
  192. strNewCommonData = strNewCommonData & strNameD & strName & strValueD & strValue
  193. ElseIf InStr(LCase(strOldCommonData), strNameD & strName & strValueD) <> 0 Then
  194. ' in body page
  195. strNewCommonData = strNewCommonData & strNameD & strName & strValueD & strValue
  196. ElseIf intOldEmbIndex <> -1 And Request.Form("PageName") = "TaskExtension" Then
  197. 'extension page - update data for current page
  198. If InStr(LCase(strOldCommonData), strNameD & strName & strValueD) = 0 Then
  199. strNewEmbData(intOldEmbIndex) = strNewEmbData(intOldEmbIndex) & strNameD & strName & strValueD & strValue
  200. End If
  201. End If
  202. End If
  203. Next
  204. Response.Write "<input name=" & chr(34) & "EmbedPageIndex" & Chr(34) & " type=hidden value=" & Chr(34) & mintElementIndex & Chr(34) & ">" & vbCrLf
  205. Response.Write "<input name=" & chr(34) & "EmbedPageCount" & Chr(34) & " type=hidden value=" & Chr(34) & mintElementCount & Chr(34) & ">" & vbCrLf
  206. Response.Write "<input name=" & chr(34) & "CommonValues" & Chr(34) & " type=hidden value=" & Chr(34) & Server.HTMLEncode(strNewCommonData) & Chr(34) & ">" & vbCrLf
  207. For i = 0 To mintElementCount-1
  208. Response.Write "<input name=" & chr(34) & "EmbedValues" & i & Chr(34) & " type=hidden value=" & Chr(34) & strNewEmbData(i) & Chr(34) & ">" & vbCrLf
  209. If mstrPageType="finish" Then ' serve out embed values discretely in Finish page
  210. If UnpackData(strNewEmbData(i), arrName, arrValue, strNameD, strValueD) Then
  211. For j = 0 To UBound(arrName)
  212. Response.Write "<input name=" & chr(34) & arrName(j) & Chr(34) & " type=hidden value=" & Chr(34) & arrValue(j) & Chr(34) & ">" & vbCrLf
  213. Next
  214. End If
  215. End If
  216. Next
  217. If mstrPageName = "TaskExtension" Then
  218. If UnpackData(strNewCommonData, arrName, arrValue, strNameD, strValueD) Then ' serve out common data as discreet form values
  219. For i = 0 To UBound(arrName)
  220. Response.Write "<input name=" & chr(34) & arrName(i) & Chr(34) & " type=hidden value=" & Chr(34) & arrValue(i) & Chr(34) & ">" & vbCrLf
  221. Next
  222. End If
  223. End If
  224. End Function
  225. '----------------------------------------------------------------------------
  226. '
  227. ' Function : UnPackData
  228. '
  229. ' Synopsis : Unpacks service specific form values from one string into
  230. ' individual <name, value> pairs
  231. '
  232. ' Arguments: InputStrings(IN) - input form variable (which contains all
  233. ' <form, value> pairs as one string
  234. ' arrName(OUT) - on output contains all service form value names
  235. ' arrValue(OUT) - on output contains all service form value values
  236. ' strNameD(IN) - delimiter between names in InputString
  237. ' strValueD(IN) - delimiter between values in InputString
  238. '
  239. ' Returns : None
  240. '
  241. '----------------------------------------------------------------------------
  242. Function UnPackData(InputString, arrName, arrValue, strNameD, strValueD)
  243. Dim intPos1, intPos2
  244. Dim intIndex
  245. On Error Resume Next
  246. InputString = LTrim(InputString)
  247. If InputString = "" Then
  248. UnPackData = False
  249. Exit Function
  250. End If
  251. If Left(InputString, 2) = strNameD Then
  252. InputString = Right(InputString, Len(InputString) - 2)
  253. End If
  254. intIndex = 0
  255. intPos1 = InStr(InputString, strValueD)
  256. intPos2 = -1
  257. Do While intPos1 <> 0
  258. ReDim Preserve arrName(intIndex)
  259. ReDim Preserve arrValue(intIndex)
  260. arrName(intIndex) = Trim(Mid(InputString, intPos2 + 2, intPos1 - intPos2 - 2))
  261. intPos2 = InStr(intPos1, InputString, strNameD)
  262. If intPos2 = 0 Then
  263. intPos2 = Len(InputString) + 1 'assumes no end delimiter
  264. End If
  265. arrValue(intIndex) = Trim(Mid(InputString, intPos1 + 1, intPos2 - intPos1 - 1))
  266. If intPos2 + 1 < Len(InputString) Then
  267. intPos1 = InStr(intPos2 + 2, InputString, strValueD)
  268. Else
  269. Exit Do
  270. End If
  271. intIndex = intIndex + 1
  272. Loop
  273. UnPackData = True
  274. End Function
  275. Function ServeTaskMainFrame() %>
  276. <html>
  277. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  278. <head>
  279. <title>frmMain</title>
  280. <script language=JavaScript src="/sh_page.js"></script>
  281. </head>
  282. <body onLoad="window.location=GetTargetURL();">
  283. &nbsp;
  284. </body>
  285. </html>
  286. <%
  287. End Function
  288. '==================================================
  289. Function ServeTaskFooterFrame()
  290. On Error Resume Next
  291. %>
  292. <html>
  293. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  294. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  295. <head>
  296. <title>Footer</title>
  297. <link rel="STYLESHEET" type="text/css" href="../sh_task.css">
  298. <script language=JavaScript src="../sh_page.js"></script>
  299. <script language=JavaScript src="../sh_task.js"></script>
  300. <script language=JavaScript>
  301. function Init() {
  302. var formTask;
  303. if (IsIE())
  304. formTask = parent.main.frmTask;
  305. else
  306. formTask = parent.main.document.forms["frmTask"];
  307. if (formTask) {
  308. var strTaskType = formTask.TaskType.value;
  309. var strPageType = formTask.PageType.value;
  310. if (IsIE())
  311. document.onkeypress = HandleKeyPress;
  312. switch (strTaskType) {
  313. case "<% =PROPSHEET_TASK %>":
  314. if (IsIE()) {
  315. PropertyPageButtons.style.display = "";
  316. WizardButtons.style.display = "none";
  317. var tblTaskP = parent.main.document.all("TASKTABLE");
  318. if (tblTaskP)
  319. tblTaskP.focus();
  320. }
  321. else {
  322. document.layers["PropertyPageButtons"].visibility = "show";
  323. document.layers["WizardButtons"].visibility = "hide";
  324. document.layers["WizardButtons_Finish"].visibility = "hide";
  325. }
  326. top.main.main.EnableCancel();
  327. top.main.main.EnableOK();
  328. switch (strPageType) {
  329. case "failure":
  330. document.frmFooter.butOK.style.display = "none";
  331. break;
  332. default:
  333. break;
  334. }
  335. break;
  336. case "<% =WIZARD_TASK %>":
  337. if (IsIE()) {
  338. WizardButtons.style.display = "";
  339. PropertyPageButtons.style.display = "none";
  340. var tblTaskW = parent.main.document.all("TASKTABLE");
  341. if (tblTaskW)
  342. tblTaskW.focus();
  343. }
  344. else {
  345. document.layers["PropertyPageButtons"].visibility = "hide";
  346. }
  347. top.main.main.EnableBack();
  348. top.main.main.EnableNext();
  349. top.main.main.EnableCancel();
  350. switch (strPageType) {
  351. case "<% =INTRO_PAGE %>":
  352. top.main.main.DisableBack();
  353. if (!IsIE()) {
  354. document.layers["WizardButtons_Finish"].visibility = "hide";
  355. document.layers["WizardButtons"].visibility = "show";
  356. }
  357. break;
  358. case "<% =FINISH_PAGE %>":
  359. if (IsIE()) {
  360. document.frmFooter.butNext.style.display = "none";
  361. document.frmFooter.butFinish.style.display = "";
  362. }
  363. else {
  364. document.layers["WizardButtons_Finish"].visibility = "show";
  365. document.layers["WizardButtons"].visibility = "hide";
  366. }
  367. top.main.main.EnableFinish();
  368. break;
  369. default:
  370. if (IsIE()) {
  371. document.frmFooter.butNext.style.display = "";
  372. document.frmFooter.butFinish.style.display = "none";
  373. }
  374. else {
  375. document.layers["WizardButtons"].visibility = "show";
  376. document.layers["WizardButtons_Finish"].visibility = "hide";
  377. }
  378. break;
  379. }
  380. break;
  381. default:
  382. if (IsIE())
  383. PropertyPageButtons.style.display = "";
  384. break;
  385. }
  386. }
  387. else
  388. window.setTimeout('Init();',50);
  389. }
  390. function HandleKeyPress(evnt) {
  391. var intKeyCode;
  392. var frameMain = parent.main;
  393. if (window.event.srcElement.tagName=='BUTTON' || window.event.srcElement.tagName=='INPUT' )
  394. return;
  395. if (frameMain.readyState=='uninitialized' || frameMain.readyState=='loading')
  396. return;
  397. if (frameMain.Task.KeyPress==true || frameMain.Task.NavClick==true)
  398. return;
  399. intKeyCode = window.event.keyCode;
  400. if (intKeyCode == 13) {
  401. frameMain.Task.KeyPress = true;
  402. if (frameMain.Task.PageType != "finish") {
  403. if (document.frmFooter.butNext != null || document.frmFooter.butOK != null)
  404. frameMain.Next();
  405. } else {
  406. if (document.frmFooter.butFinish != null)
  407. frameMain.FinishShell();
  408. }
  409. }
  410. if (intKeyCode == 27) {
  411. frameMain.Task.KeyPress = true;
  412. frameMain.Cancel();
  413. }
  414. }
  415. </script>
  416. </head>
  417. <BODY onLoad="Init();" oncontextmenu="return false;" topmargin="0" leftmargin="0" rightmargin="0" onDragDrop="return false;" tabindex=-1>
  418. <% If Not IsIE() Then %>
  419. <layer ID="WizardButtons" visibility="hide" style="z-index:1; position:absolute; width:100%; top:0px;">
  420. <FORM name="frmFooter">
  421. <table width=100% cellspacing=10 cellpadding=0 border=0><tr><td width=95%></td>
  422. <td>
  423. <input name="butBack" class="NAVBUTTON" type="button" value="<% =L_BACK_BUTTON %>"
  424. onClick="if (parent.main.document.forms['frmTask']) parent.main.Back();">
  425. </td><td>
  426. <input name="butNext" class="NAVBUTTON" type="button" value="<% =L_NEXT_BUTTON %>"
  427. onClick="if (parent.main.document.forms['frmTask']) parent.main.Next();">
  428. </td><td>
  429. <input name="butCancelW" class="NAVBUTTON" type="button" value="<% =L_CANCEL_BUTTON %>"
  430. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();">
  431. </td></tr></table>
  432. </form>
  433. </layer>
  434. <layer ID="WizardButtons_Finish" visibility="hide" style="z-index:1; position:absolute; width:100%; top:0px;">
  435. <FORM name="frmFooter">
  436. <table width=100% cellspacing=10 cellpadding=0 border=0><tr><td width=95%></td>
  437. <td>
  438. <input name="butBack" class="NAVBUTTON" type="button" value="<% =L_BACK_BUTTON %>"
  439. onClick="if (parent.main.document.forms['frmTask']) parent.main.Back();">
  440. </td><td>
  441. <input name="butFinish" type="button" value="<% =L_FINISH_BUTTON %>" class="NAVBUTTON"
  442. onClick="if (parent.main.document.forms['frmTask']) parent.main.FinishShell();">
  443. </td><td>
  444. <input name="butCancelW" class="NAVBUTTON" type="button" value="<% =L_CANCEL_BUTTON %>"
  445. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();">
  446. </td></tr></table>
  447. </form>
  448. </layer>
  449. <layer ID="PropertyPageButtons" visibility="hide" style="z-index:1; position:absolute; top:0px;">
  450. <FORM name="frmFooter">
  451. <table width=100% cellspacing=10 cellpadding=0 border=0>
  452. <tr><td width=90% ></td><td >
  453. <input type=button align=right value="<% =L_OK_BUTTON %>" alt="OK" name="butOK" class="NAVBUTTON"
  454. onClick="if (parent.main.document.forms['frmTask']) parent.main.Next();">
  455. &nbsp;
  456. </td><td>
  457. <input type="button" name="butCancelP" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  458. onClick="if (parent.main.document.forms['frmTask']) parent.main.Cancel();" class="NAVBUTTON">
  459. &nbsp;
  460. </td></tr></table>
  461. </form>
  462. </layer>
  463. <%
  464. Else %>
  465. <FORM name="frmFooter">
  466. <DIV ID="WizardButtons" style="display:none; position:absolute; top:10px; ">
  467. <table width=100% cellspacing=0 cellpadding=0><tr><td width=100% ></td><td nowrap>
  468. <button name="butBack" id="but_back01" class="NAVBUTTON" accesskey="<% =L_BACK_ACCESSKEY %>" alt="<% =L_BACK_BUTTON %>"
  469. onClick="if (parent.main.frmTask) parent.main.Back();"><% =L_BACKIE_BUTTON %></button>
  470. <button name="butNext" id="but_next01" class="NAVBUTTON" accesskey="<% =L_NEXT_ACCESSKEY %>" alt="<% =L_NEXT_BUTTON %>"
  471. onClick="if (parent.main.frmTask) parent.main.Next();"><% =L_NEXTIE_BUTTON %></button>
  472. <input type="button" name="butFinish" value="<% =L_FINISH_BUTTON %>" alt="Finish" class="NAVBUTTON"
  473. style="display:none"
  474. onClick="if (parent.main.frmTask) parent.main.FinishShell();">
  475. &nbsp;
  476. <input type="button" name="butCancelW" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  477. style=""
  478. onClick="if (parent.main.frmTask) parent.main.Cancel();" class="NAVBUTTON">
  479. &nbsp;
  480. </td></tr></table>
  481. </div>
  482. <DIV ID="PropertyPageButtons" style="display:none; position:absolute; top:10px;">
  483. <table width=100% cellspacing=0 cellpadding=0><tr><td width=100% ></td><td nowrap>
  484. <input type=button align=right value="<% =L_OK_BUTTON %>" alt="OK" name="butOK" class="NAVBUTTON" onClick="if (parent.main.frmTask) parent.main.Next();">
  485. &nbsp;
  486. <input type="button" name="butCancelP" value="<% =L_CANCEL_BUTTON %>" alt="<% =L_CANCEL_BUTTON %>"
  487. onClick="if (parent.main.frmTask) parent.main.Cancel();" class="NAVBUTTON">
  488. &nbsp;
  489. </td></tr></table>
  490. </div>
  491. </form>
  492. <% End If
  493. Response.Write "</BODY></HTML>"
  494. End Function
  495. '----------------------------------------------------------------------------
  496. '
  497. ' Function : ServeTaskHeader
  498. '
  499. ' Synopsis : Serve the task header based on page type
  500. ' Note: Uses module-level variables listed below. These values
  501. ' are set for each task and page as needed.
  502. ' mstrTaskType - "wizard", "prop"
  503. ' mstrPageType - "intro", "finish", "standard"
  504. ' mintElementIndex - index of wizard extension page, (0 - n)
  505. ' mintElementCount - count of extension pages
  506. ' mblnFinishDirect - finish button behavior
  507. ' mblnCancelDirect - cancel button behaviormblnCancelDirect
  508. '
  509. ' Arguments: None
  510. '
  511. ' Returns : None
  512. '
  513. '----------------------------------------------------------------------------
  514. Function ServeTaskHeader()
  515. 'Inputs: none
  516. '
  517. Dim objItem
  518. On Error Resume Next
  519. Response.Buffer = True
  520. 'Response.Expires = 0
  521. 'Response.AddHeader "pragma", "no-cache"
  522. %>
  523. <html LANG="en">
  524. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  525. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  526. <head>
  527. <title><% =mstrTaskTitle %></title>
  528. <script language=JavaScript src="../sh_page.js"></script>
  529. <script language=JavaScript src="../sh_task.js"></script>
  530. <link rel="STYLESHEET" type="text/css" href="../sh_task.css">
  531. </head>
  532. <BODY marginWidth="0" marginHeight="0" onload="PageInit();" topmargin="0" leftmargin="0" rightmargin="0" onDragDrop="return false;" oncontextmenu="//return false;">
  533. <FORM name="frmTask" onSubmit="return Next();" action="<% =GetScriptFileName %>" method="POST">
  534. <INPUT name="PageName" type="hidden" value="<% =mstrPageName %>">
  535. <INPUT name="Method" type="hidden" value="<% =mstrMethod %>">
  536. <INPUT name="ReturnURL" type="hidden" value="<% =mstrReturnURL %>">
  537. <INPUT name="TaskType" type="hidden" value="<% =mstrTaskType %>">
  538. <INPUT name="PageType" type="hidden" value="<% =mstrPageType %>">
  539. <INPUT name="FinishDirect" type="hidden" value="<% =mblnFinishDirect %>">
  540. <INPUT name="CancelDirect" type="hidden" value="<% =mblnCancelDirect %>">
  541. <%
  542. ' conditionally serve hidden form elements from extended
  543. ' task page
  544. if mstrTaskType="wizard" then
  545. ServeFormValues()
  546. end if
  547. %>
  548. <% If( (mstrTaskType="wizard") AND (mstrPageType="intro" OR mstrPageType="finish")) Then %>
  549. <TABLE width=100% height=88% border=0 cellspacing=0 cellpadding=0 ID=TASKTABLE>
  550. <TR valign=TOP style="background-color:#FFFFFF">
  551. <TD width="10%" align="right" valign=TOP style="width:130px; background-color: #313163">
  552. <IMG width=130 border=0 src="<% =mstrPanelPath %>">
  553. </td>
  554. <TD width=18 valign=TOP style="background-color: white;">
  555. &nbsp;&nbsp;
  556. </td>
  557. <TD valign=TOP style="background-color: white;">
  558. <span class="TASKTITLE"><% =mstrTaskTitle %></span>
  559. <BR><BR>
  560. <% Else %>
  561. <TABLE width=100% border=0 height="88%" cellspacing=0 cellpadding=0 ID=TASKTABLE >
  562. <TR valign=TOP height="10%" style="background-color:#FFFFFF">
  563. <TD width=3% height="10%" valign=TOP>
  564. &nbsp;&nbsp;
  565. </TD>
  566. <TD valign=TOP>
  567. <span CLASS="TASKTITLE"><%=mstrTaskTitle %></span><BR>
  568. &nbsp;&nbsp;&nbsp;<span class="PAGETITLE"><% =mstrPageTitle %></span>
  569. </TD>
  570. <TD align="right" valign=TOP bgcolor="#FFFFFF">
  571. <IMG height=64 width=64 border=0 src="<% =mstrIconPath %>">
  572. </TD>
  573. </TR>
  574. <TR height="80%" valign=TOP>
  575. <TD width=26px height=64 valign=TOP>
  576. &nbsp;&nbsp;
  577. </TD>
  578. <TD valign="top" height="70%" colspan=2>
  579. <BR>
  580. <% End IF%>
  581. <%
  582. ServeTaskHeader = True
  583. End Function
  584. '==================================================
  585. Function ServeTaskHeader1()
  586. 'Inputs: none
  587. '
  588. ' Notes: Uses module-level variables,
  589. ' listed below. These values are set
  590. ' for each task and page as needed.
  591. ' mstrTaskType - "wizard", "prop"
  592. ' mstrPageType - "intro", "finish", "standard"
  593. ' mintElementIndex - index of wizard extension page, (0 - n)
  594. ' mintElementCount - count of extension pages
  595. ' mblnFinishDirect - finish button behavior
  596. ' mblnCancelDirect - cancel button behaviormblnCancelDirect
  597. Dim objItem
  598. On Error Resume Next
  599. Response.Buffer = True
  600. 'Response.Expires = 0
  601. 'Response.AddHeader "pragma", "no-cache"
  602. %>
  603. <html LANG="en">
  604. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  605. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  606. <head>
  607. <title><% =mstrTaskTitle %></title>
  608. <script language=JavaScript src="../sh_page.js"></script>
  609. <script language=JavaScript src="../sh_task.js"></script>
  610. <link rel="STYLESHEET" type="text/css" href="../sh_task.css">
  611. </head>
  612. <BODY marginWidth="0" marginHeight="0" onload="PageInit();" topmargin="0" leftmargin="0" rightmargin="0" onDragDrop="return false;" oncontextmenu="//return false;">
  613. <FORM name="frmTask" onSubmit="return Next();" action="<% =GetScriptFileName %>" method="POST">
  614. <INPUT name="PageName" type="hidden" value="<% =mstrPageName %>">
  615. <INPUT name="Method" type="hidden" value="<% =mstrMethod %>">
  616. <INPUT name="ReturnURL" type="hidden" value="<% =mstrReturnURL %>">
  617. <INPUT name="TaskType" type="hidden" value="<% =mstrTaskType %>">
  618. <INPUT name="PageType" type="hidden" value="<% =mstrPageType %>">
  619. <INPUT name="FinishDirect" type="hidden" value="<% =mblnFinishDirect %>">
  620. <INPUT name="CancelDirect" type="hidden" value="<% =mblnCancelDirect %>">
  621. <%
  622. ' conditionally serve hidden form elements from extended
  623. ' task page
  624. if mstrTaskType="wizard" then
  625. ServeFormValues()
  626. end if
  627. %>
  628. <TABLE width=100% height="90%" border=0 cellspacing=0 cellpadding=0 >
  629. <TR valign=TOP height="100%" width="10%" style="background-color:#FFFFFF">
  630. <TD height="100%" width="15%" valign=TOP style="background-color:#000000">
  631. <IMG height="100" width="100" border=0 src="../images/aboutbox_water.gif">
  632. </TD>
  633. <td height="100%" width="5%">&nbsp;</td>
  634. <td >
  635. <span CLASS="TASKTITLE"><%=mstrTaskTitle %></span><BR><br><br>
  636. <%
  637. ServeTaskHeader1 = True
  638. End Function
  639. '----------------------------------------------------------------------------
  640. '
  641. ' Function : ServeTaskFooter
  642. '
  643. ' Synopsis : Serve the task footer (navigation buttons & error div)
  644. ' Note: The function relies on the following module-level variables:
  645. ' mstrTaskType - prop wizard
  646. ' mstrPageType - standard intro finish failure
  647. '
  648. ' Arguments: None
  649. '
  650. ' Returns : None
  651. '
  652. '----------------------------------------------------------------------------
  653. Function ServeTaskFooter()
  654. On Error Resume Next %>
  655. <BR>
  656. </TD>
  657. </TR>
  658. <% If (IsIE()) Then %>
  659. <TR>
  660. <TD>&nbsp;</TD>
  661. <TD><DIV name="divErrMsg" ID="divErrMsg" class="ErrMsg"></TD>
  662. </TR>
  663. <% End If %>
  664. </td></tr>
  665. </table>
  666. <HR>
  667. <table WIDTH="100%">
  668. <TR>&nbsp;</TR>
  669. <TR ALIGN="right">
  670. <TD>
  671. <%
  672. select Case mstrTaskType
  673. case "wizard"
  674. Select Case mstrPageType
  675. case "intro","standard"
  676. %>
  677. <INPUT name="butBack" TYPE="button" accesskey="<% =L_BACK_ACCESSKEY %>" onclick="Back();" VALUE="<%=L_BACK_BUTTON%>">
  678. <INPUT name="butNext" TYPE="button" accesskey="<% =L_NEXT_ACCESSKEY %>" onclick="Next();" VALUE="<%=L_NEXT_BUTTON%>">
  679. <INPUT name="butCancel" TYPE="button" onclick="Cancel();" VALUE="<%=L_CANCEL_BUTTON%>">
  680. <%
  681. case "finish"
  682. %>
  683. <INPUT name="butBack" TYPE="button" accesskey="<% =L_BACK_ACCESSKEY %>" onclick="Back();" VALUE="<%=L_BACK_BUTTON%>">
  684. <INPUT name="butFinish" TYPE="button" accesskey="<% =L_FINISH_ACCESSKEY %>" onclick="FinishShell();" VALUE="<%=L_FINISH_BUTTON%>">
  685. <INPUT name="butCancel" TYPE="button" onclick="Cancel();" VALUE="<%=L_CANCEL_BUTTON%>">
  686. <%
  687. end Select
  688. case "prop"
  689. %>
  690. <INPUT name="butOK" TYPE="button" onclick="Next();" VALUE="<%=L_OK_BUTTON%>">
  691. &nbsp;&nbsp;
  692. <INPUT name="butCancel" TYPE="button" onclick="Cancel();" VALUE="<%=L_CANCEL_BUTTON%>">
  693. <%
  694. end select
  695. %>
  696. </TD>
  697. </TR>
  698. </table>
  699. <% If Not IsIE() Then %>
  700. <layer name="layErrMsg" class="ErrMsg"></layer>
  701. <% End If %>
  702. <% If GetErrMsg <> "" Then
  703. Response.Write "<img src='/images/critical_g.gif' border=0>&nbsp;&nbsp;" & GetErrMsg
  704. SetErrMsg ""
  705. End If
  706. Response.Write "</div></form></BODY></HTML>"
  707. End Function
  708. '----------------------------------------------------------------------------
  709. '
  710. ' Function : ServeFailurePage
  711. '
  712. ' Synopsis : Serve the page which redirects the browser to the err_view.asp
  713. ' failure page
  714. '
  715. ' Arguments: Message(IN) - message to be displayed by err_view.asp
  716. ' intTab(IN) - Tab to be highlighted by err_view.asp
  717. '
  718. ' Returns : None
  719. '
  720. '----------------------------------------------------------------------------
  721. Function ServeFailurePage(Message, intTab)
  722. On Error Resume Next
  723. %>
  724. <html>
  725. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  726. <head>
  727. <SCRIPT language=JavaScript>
  728. function Redirect() {
  729. top.location = "/util/err_view.asp?Tab=<%=intTab%>&Message=<% =Message %>&ReturnURL=<% =mstrReturnURL %>&R=" + Math.random();
  730. }
  731. </SCRIPT>
  732. </head>
  733. <body onLoad="Redirect();" bgcolor="#000000">
  734. &nbsp;
  735. </body>
  736. </html>
  737. <%
  738. Response.End
  739. End Function
  740. '----------------------------------------------------------------------------
  741. '
  742. ' Function : ServeTaskBusyPage
  743. '
  744. ' Synopsis : Serve the task busy page
  745. '
  746. ' Arguments: Message(IN) - message to be displayed in this page
  747. '
  748. ' Returns : None
  749. '
  750. '----------------------------------------------------------------------------
  751. Sub ServeTaskBusyPage(Message)
  752. On Error Resume Next
  753. mstrPageName = "FinishFailure"
  754. mstrTaskType = "prop"
  755. mstrPageType = "failure"
  756. ServeTaskHeader
  757. %>
  758. <Script language=JavaScript>
  759. function Init() { }
  760. function SetData() { }
  761. function ValidatePage() {
  762. return true;
  763. }
  764. function Finish() {
  765. ExitTask();
  766. }
  767. </Script>
  768. <TABLE WIDTH=350 ALIGN=middle BORDER=0 CELLSPACING=1 CELLPADDING=10 style="font-family: Tahoma, Arial; font-size:10pt">
  769. <TR>
  770. <td colspan=2>
  771. <P><% =Message %></P>
  772. </td>
  773. </TR>
  774. </TABLE>
  775. <% ServeTaskFooter %>
  776. </FORM>
  777. </BODY>
  778. </HTML>
  779. <%
  780. End Sub
  781. '----------------------------------------------------------------------------
  782. '
  783. ' Function : ServeClose
  784. '
  785. ' Synopsis : Redirect user to the page from which the wizard was launched
  786. '
  787. ' Arguments: None
  788. '
  789. ' Returns : None
  790. '
  791. '----------------------------------------------------------------------------
  792. Sub ServeClose
  793. response.redirect mstrReturnURL
  794. On Error Resume Next
  795. %>
  796. <html>
  797. <!-- Copyright (c) 1999 - 2000 Microsoft Corporation. All rights reserved.-->
  798. <head>
  799. <SCRIPT language=JavaScript>
  800. function Redirect()
  801. {
  802. var strURL;
  803. strURL = '<%=mstrReturnURL%>';
  804. if (strURL == '')
  805. {
  806. strURL = '/default.asp';
  807. }
  808. if (strURL.indexOf('?') != -1)
  809. {
  810. strURL += "&";
  811. }
  812. else
  813. {
  814. strURL += "?";
  815. }
  816. strURL += "R=" + Math.random();
  817. top.location=strURL;
  818. }
  819. </SCRIPT>
  820. </head>
  821. <body onLoad="Redirect();" bgcolor="Silver">
  822. &nbsp;
  823. </body>
  824. </html>
  825. <%
  826. End Sub
  827. '----------------------------------------------------------------------------
  828. '
  829. ' Function : ServePropEmbeds
  830. '
  831. ' Synopsis : Serve the embedded property pages
  832. '
  833. ' Arguments: None
  834. '
  835. ' Returns : None
  836. '
  837. '----------------------------------------------------------------------------
  838. '=================================================================
  839. Function ServePropEmbeds()
  840. Dim objElementCol
  841. Dim objElement
  842. Dim rc
  843. On Error Resume Next
  844. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  845. For Each objElement in objElementCol
  846. rc = GetEmbedHTML(objElement, 0)
  847. Next
  848. Set objElementCol = Nothing
  849. ServePropEmbeds = True
  850. End Function
  851. '----------------------------------------------------------------------------
  852. '
  853. ' Function : ServeWizardEmbeds
  854. '
  855. ' Synopsis : Handles navigation through wizard extension pages.
  856. ' Note: uses module-level value mstrMethod
  857. '
  858. ' Arguments: TopPage(IN) - the page just before the first embedded page
  859. ' in the wizard.
  860. ' BottomPage(IN) - the page just after the last embedded page
  861. ' in the wizard.
  862. '
  863. ' Returns : Returns true or false if HTML is output. Writes wizard HTML
  864. ' to the client.
  865. ' mintElementIndex is set here after getting the initial value
  866. '
  867. '----------------------------------------------------------------------------
  868. Function ServeWizardEmbeds(TopPage, BottomPage)
  869. Dim booServedPage
  870. Dim objElementCol
  871. Dim objElement
  872. Dim arrElementID()
  873. Dim intOrigIndex
  874. Dim i
  875. On Error Resume Next
  876. mintElementIndex = CInt(Request.Form("EmbedPageIndex"))
  877. Response.Buffer = True
  878. booServedPage = False
  879. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  880. mintElementCount = objElementCol.Count
  881. ReDim arrElementID(mintElementCount)
  882. i = 0
  883. For Each objElement in objElementCol
  884. arrElementID(i) = objElement.GetProperty("ElementID")
  885. i = i + 1
  886. Next
  887. If LCase(mstrPageName) = LCase(TopPage) Then
  888. ' entering start of extension (method=NEXT, currentpage=TopPage)
  889. For mintElementIndex = 0 to UBound(arrElementID)-1
  890. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  891. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  892. booServedPage = True
  893. Exit For
  894. End If
  895. Next
  896. If Not booServedPage Then
  897. ServePage(BottomPage)
  898. End If
  899. ElseIf mstrPageName = BottomPage Then
  900. ' entering end of extension (method=BACK, currentpage=BottomPage)
  901. For mintElementIndex = UBound(arrElementID)-1 to 0 Step -1
  902. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  903. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  904. booServedPage = True
  905. Exit For
  906. End If
  907. Next
  908. If Not booServedPage Then
  909. ServePage(TopPage)
  910. End If
  911. Else
  912. 'Inside the extension pages (method=NEXT | BACK, currentpage="ExtensionPage" )
  913. intOrigIndex = mintElementIndex
  914. If mstrMethod = "NEXT" Then
  915. For mintElementIndex = intOrigIndex + 1 to UBound(arrElementID)-1
  916. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  917. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  918. booServedPage = True
  919. Exit For
  920. End If
  921. Next
  922. If Not booServedPage Then
  923. ServePage(BottomPage)
  924. End If
  925. ElseIf mstrMethod = "BACK" Then
  926. For mintElementIndex = intOrigIndex - 1 To 0 Step -1
  927. Set objElement = objElementCol.Item(arrElementID(mintElementIndex))
  928. If ServeEmbedWizardPage(objElement, mintElementIndex) Then
  929. booServedPage = True
  930. Exit For
  931. End If
  932. Next
  933. If Not booServedPage Then
  934. ServePage(TopPage)
  935. End If
  936. End If
  937. End If
  938. Set objElementCol = Nothing
  939. Set objElement = Nothing
  940. End Function
  941. '----------------------------------------------------------------------------
  942. '
  943. ' Function : ServeEmbedWizardPage
  944. '
  945. ' Synopsis : Serve the embedded wizard pages. Handles the actual building of
  946. ' the page
  947. '
  948. ' Arguments: Element(IN) - the element obj for the wizard page to be
  949. ' served.
  950. ' ElementIndex(IN) - element index
  951. '
  952. ' Returns : None
  953. '
  954. '----------------------------------------------------------------------------
  955. Function ServeEmbedWizardPage(Element, ElementIndex)
  956. On Error Resume Next
  957. 'set task framework variables
  958. mstrPageName = "TaskExtension"
  959. mstrPageType = "standard"
  960. mstrTaskType = "wizard"
  961. intCaptionIDTask = "&H" & Element.GetProperty("CaptionRID")
  962. strSourceName = ""
  963. strSourceName = Element.GetProperty ("Source")
  964. Err.Clear
  965. If strSourceName = "" Then
  966. strSourceName = "svrapp"
  967. End If
  968. Err.Clear
  969. mstrPageTitle = objLocMgr.GetString(strSourceName, intCaptionIDTask, varReplacementStrings)
  970. If Err <> 0 Then
  971. Err.Clear
  972. mstrPageTitle = ""
  973. End If
  974. ServeTaskHeader
  975. If GetEmbedHTML(Element, 0) Then
  976. ServeTaskFooter
  977. ServeEmbedWizardPage = True
  978. Else
  979. ServeEmbedWizardPage = False
  980. Response.Clear
  981. End If
  982. End Function
  983. '----------------------------------------------------------------------------
  984. '
  985. ' Function : ExecuteTask
  986. '
  987. ' Synopsis : Calls Microsoft_SA_Task object by name
  988. '
  989. ' Arguments: TaskName(IN) - name of task to execute.
  990. ' TaskContext(IN) - empty task parameters object. Parameters in the
  991. ' form of hidden form values are added to this
  992. ' object before the task is executed.
  993. ' also mstrAsyncTaskName: if not empty, call task asynchronously
  994. '
  995. ' Returns : HRESULT from ExecuteTask, or
  996. ' 1 - TaskContext instantiation failed
  997. ' 2 - AppSrvcs instantiation failed
  998. ' 3 - AppSrvcs init failed
  999. ' TaskContext: populated ITaskContext
  1000. '
  1001. '----------------------------------------------------------------------------
  1002. Function ExecuteTask(TaskName, TaskContext)
  1003. '
  1004. ' ExecuteTask -
  1005. '
  1006. ' INPUT TaskName: string, TaskName property of Task instance
  1007. ' TaskContext: empty ITaskContext
  1008. '
  1009. ' also mstrAsyncTaskName: if not empty, call task asynchronously
  1010. '
  1011. ' OUTPUT retval: HRESULT from ExecuteTask, or
  1012. ' 1 - TaskContext instantiation failed
  1013. ' 2 - AppSrvcs instantiation failed
  1014. ' 3 - AppSrvcs init failed
  1015. ' TaskContext: populated ITaskContext
  1016. Dim objAS
  1017. Dim objTaskContext
  1018. Dim objValue
  1019. Dim objElementCol
  1020. Dim objElement
  1021. Dim varValue
  1022. Dim strName
  1023. Dim arrName
  1024. Dim arrValue
  1025. Dim rc
  1026. Dim i
  1027. On Error Resume Next
  1028. Set objTaskContext = Server.CreateObject("Taskctx.TaskContext")
  1029. If Err <> 0 Then
  1030. ExecuteTask = 1
  1031. Else
  1032. Set objAS = Server.CreateObject("Appsrvcs.ApplianceServices")
  1033. If Err <> 0 Then
  1034. ExecuteTask = 2
  1035. Else
  1036. objAS.Initialize()
  1037. If Err = 0 Then
  1038. For Each objValue in Request.Form
  1039. strName = objValue
  1040. If InStr(mstrFrmwrkFormStrings, "!" & strName & "!") = 0 Then 'set normal form value data
  1041. varValue = Request.Form(objValue)
  1042. objTaskContext.SetParameter strName, varValue
  1043. End If
  1044. Next
  1045. objTaskContext.SetParameter PROPERTY_TASK_NICE_NAME, mstrTaskTitle
  1046. objTaskContext.SetParameter PROPERTY_TASK_URL, "/" & GetScriptPath()
  1047. Err.Clear
  1048. If mstrAsyncTaskName <> "" Then
  1049. rc = objAS.ExecuteTaskAsync(TaskName, objTaskContext)
  1050. If rc = WBEM_E_PROVIDER_NOT_CAPABLE Then
  1051. ServeTaskBusy
  1052. End If
  1053. Else
  1054. rc = objAS.ExecuteTask(TaskName, objTaskContext)
  1055. End If
  1056. ' check for and handle errors in embedded pages
  1057. If rc <> 0 And mstrTaskType = "wizard" And mintElementCount > 0 Then
  1058. mintElementCount = 0
  1059. Set objElementCol = GetElements(GetScriptPath()) 'retrieve elements based on the task path
  1060. mintElementCount = objElementCol.Count
  1061. mintElementIndex = 0
  1062. For Each objElement in objElementCol
  1063. If ServeEmbedWizardPage(objElement, mintElementIndex, rc) Then
  1064. Err.Clear
  1065. ExecuteTask = rc
  1066. Else
  1067. mintElementIndex = mintElementIndex + 1
  1068. End If
  1069. Next
  1070. Set objElementCol = Nothing
  1071. Set objElement = Nothing
  1072. End If
  1073. ExecuteTask = Err.Number
  1074. Err.Clear
  1075. Set TaskContext = objTaskContext
  1076. objAS.Shutdown()
  1077. Else
  1078. ExecuteTask = 3
  1079. End If
  1080. End If
  1081. End If
  1082. Err.Clear
  1083. Set objAS = Nothing
  1084. Set objTaskContext = Nothing
  1085. End Function
  1086. %>