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.

207 lines
6.8 KiB

  1. <%@ Language=VBScript %>
  2. <%Option Explicit%>
  3. <%
  4. '-------------------------------------------------------------------------
  5. 'Shutdown_restartConfirm.asp: Restart the server appliance.
  6. '
  7. 'Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. 'Date Description
  10. '02-Jan-2001 Created date
  11. '23-Mar-2001 Modified date
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!--#include virtual="/admin/inc_framework.asp"-->
  15. <!-- #include file="loc_Shutdown_msg.asp" -->
  16. <!-- #include file="inc_Shutdown.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. 'Global Variables
  20. '-------------------------------------------------------------------------
  21. Dim page 'Variable that receives the output page object when
  22. 'creating a page
  23. 'Create a property page
  24. Call SA_CreatePage(L_RESTARTPAGE_TITLE_TEXT,"images/critical_error.gif",PT_PROPERTY,page)
  25. Call SA_ShowPage(page)
  26. '-------------------------------------------------------------------------
  27. 'Function: OnInitPage()
  28. 'Description: Called to signal first time processing for this page.
  29. ' Use this method to do first time initialization tasks
  30. 'Input Variables: PageIn,EventArg
  31. 'Output Variables: PageIn,EventArg
  32. 'Returns: True/False
  33. 'Global Variables: None
  34. '-------------------------------------------------------------------------
  35. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  36. Call SA_TraceOut("shutdown_restartConfirm.asp", "OnInitPage")
  37. OnInitPage=TRUE
  38. End Function
  39. '-------------------------------------------------------------------------
  40. 'Function: OnServePropertyPage()
  41. 'Description: Called when the page needs to be served.Use this
  42. ' method to serve content
  43. 'Input Variables: PageIn,EventArg
  44. 'Output Variables: PageIn,EventArg
  45. 'Returns: True/False
  46. 'Global Variables: L_RESTARTCONFIRM_MESSAGE_TEXT
  47. '-------------------------------------------------------------------------
  48. Public Function OnServePropertyPage(ByRef PageIn,ByRef EventArg)
  49. Call SA_TraceOut("shutdown_restartConfirm.asp", "OnServePropertyPage")
  50. 'Serve the client side script
  51. Call ServeCommonJavaScript()
  52. %>
  53. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
  54. <TR>
  55. <TD CLASS="TasksBody" >
  56. <%=L_RESTARTCONFIRM_MESSAGE_TEXT%>
  57. </TD>
  58. </TR>
  59. </TABLE>
  60. <%
  61. OnServePropertyPage=TRUE
  62. End Function
  63. '-------------------------------------------------------------------------
  64. 'Function: OnPostBackPage()
  65. 'Description: Called to signal that the page has been posted-back.
  66. 'Input Variables: PageIn,EventArg
  67. 'Output Variables: PageIn,EventArg
  68. 'Returns: True/False
  69. 'Global Variables: None
  70. '-------------------------------------------------------------------------
  71. Public Function OnPostBackPage(ByRef PageIn,ByRef EventArg)
  72. Call SA_TraceOut("shutdown_restartConfirm.asp", "OnPostBackPage")
  73. OnPostBackPage=TRUE
  74. End Function
  75. '-------------------------------------------------------------------------
  76. 'Function: OnSubmitPage()
  77. 'Description: Called when the page has been submitted for processing.
  78. ' Use this method to process the submit request.
  79. 'Input Variables: PageIn,EventArg
  80. 'Output Variables: PageIn,EventArg
  81. 'Returns: True/False
  82. 'Global Variables: None
  83. '-------------------------------------------------------------------------
  84. Public Function OnSubmitPage(ByRef PageIn,ByRef EventArg)
  85. Call SA_TraceOut("shutdown_restartConfirm.asp", "OnSubmitPage")
  86. OnSubmitPage=blnRestartAppliance()
  87. End Function
  88. '-------------------------------------------------------------------------
  89. 'Function: OnClosePage()
  90. 'Description: Called when the page is about to be closed.Use this method
  91. ' to perform clean-up processing
  92. 'Input Variables: PageIn,EventArg
  93. 'Output Variables: PageIn,EventArg
  94. 'Returns: True/False
  95. 'Global Variables: None
  96. '-------------------------------------------------------------------------
  97. Public Function OnClosePage(ByRef PageIn,ByRef EventArg)
  98. Call SA_TraceOut("shutdown_restartConfirm.asp", "OnClosePage")
  99. OnClosePage=TRUE
  100. End Function
  101. '---------------------------------------------------------------------
  102. ' Function name: ServeCommonJavaScript()
  103. ' Description: Common Javascript function to be included
  104. ' Input Variables: None
  105. ' Output Variables: None
  106. ' Return Values: None
  107. ' Global Variables: None
  108. '---------------------------------------------------------------------
  109. Function ServeCommonJavaScript()
  110. Call SA_TraceOut("shutdown_restartConfirm.asp", "ServeCommonJavaScript")
  111. %>
  112. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  113. </script>
  114. <script language="JavaScript">
  115. function Init()
  116. {
  117. return true;
  118. }
  119. function ValidatePage()
  120. {
  121. return true;
  122. }
  123. function SetData()
  124. {
  125. return true;
  126. }
  127. </script>
  128. <% End Function
  129. '-------------------------------------------------------------------------
  130. 'Function name: blnRestartAppliance
  131. 'Description: To restart the system
  132. 'Input Variables: None
  133. 'Output Variables: None
  134. 'Returns: None
  135. 'Global Variables: In:L_(*)-Localized Strings
  136. '-------------------------------------------------------------------------
  137. Function blnRestartAppliance()
  138. Err.Clear
  139. On Error Resume Next
  140. Const CONST_SHUTDOWNPRIVILEGE = "SeShutdownPrivilege"
  141. Dim ErrNum ' to hold error number
  142. Call SA_TraceOut("shutdown_restartConfirm.asp", "blnRestartAppliance")
  143. 'Assigning to false
  144. blnRestartAppliance=FALSE
  145. Dim objSAHelper
  146. Dim bModifiedPrivilege
  147. bModifiedPrivilege = FALSE
  148. 'Create SAHelper object
  149. Set objSAHelper = Server.CreateObject("ServerAppliance.SAHelper")
  150. if err.number <> 0 Then
  151. SA_TraceOut "Create object failed for SAHelper object", err.description
  152. else
  153. 'enable shutdown privilege
  154. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, TRUE)
  155. if err.number <> 0 Then
  156. SA_TraceOut "Enable privilege failed", err.description
  157. exit function
  158. end if
  159. end if
  160. ' Restart requested
  161. If ( ExecuteShutdownTask("0") ) Then
  162. ErrNum = Err.Number
  163. Err.Clear
  164. Call SA_ServeRestartingPage( "Restart", SA_DEFAULT, SA_DEFAULT, SA_DEFAULT, SA_DEFAULT, SA_DEFAULT )
  165. End If
  166. if ( bModifiedPrivilege ) then
  167. 'revert back to disabled state
  168. bModifiedPrivilege = objSAHelper.SAModifyUserPrivilege(CONST_SHUTDOWNPRIVILEGE, FALSE)
  169. if err.number <> 0 Then
  170. SA_TraceOut "Disable privilege failed", err.description
  171. exit function
  172. end if
  173. end if
  174. set objSAHelper = Nothing
  175. If ErrNum <> 0 Then
  176. Call SA_SetErrMsg(L_ERRORINRESTART_ERRORMESSAGE)
  177. Exit Function
  178. End If
  179. blnRestartAppliance=TRUE
  180. End Function
  181. %>