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.

258 lines
7.8 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' sysbackup.asp : Backup/Restore through terminal services client
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 14-03-2001 Modified Date
  11. '-------------------------------------------------------------------------
  12. %>
  13. <!--#include virtual="/admin/inc_framework.asp"-->
  14. <%
  15. '-------------------------------------------------------------------------------------------------
  16. 'Localized content
  17. '-------------------------------------------------------------------------------------------------
  18. DIM L_BACKUPTITLE_TEXT
  19. L_BACKUPTITLE_TEXT = SA_GetLocString("sysbackup.dll", "40700005", "")
  20. DIM L_BACKUP_WINIECLIENT_ERRORMESSAGE
  21. L_BACKUP_WINIECLIENT_ERRORMESSAGE = SA_GetLocString("sysbackup.dll", "C0700007", "")
  22. DIM L_BACKUP_SERVERCONNECTIONFAILED_ERRORMESSAGE
  23. L_BACKUP_SERVERCONNECTIONFAILED_ERRORMESSAGE = SA_GetLocString("sysbackup.dll", "C0700009", "")
  24. DIM L_UNABLETOACCESSBROWSER_ERRORMESSAGE
  25. L_UNABLETOACCESSBROWSER_ERRORMESSAGE = SA_GetLocString("sysbackup.dll", "C070000A", "")
  26. DIM L_BACKUP_HELP_MESSAGE
  27. L_BACKUP_HELP_MESSAGE = SA_GetLocString("sysbackup.dll", "4070000B", "")
  28. Dim WinNTSysInfo 'Getting object
  29. Dim strComputerName(1) 'Computer name
  30. Set WinNTSysInfo = CreateObject("WinNTSystemInfo")
  31. strComputerName(0) = WinNTSysInfo.ComputerName
  32. DIM L_ERRMSG_TITLE
  33. DIM L_ERRMSG_PROMPT
  34. L_ERRMSG_TITLE = GetLocString("tserver.dll", "40420007", "")
  35. L_ERRMSG_PROMPT = GetLocString("tserver.dll", "40420006", strComputerName)
  36. '-------------------------------------------------------------------------------------------------
  37. 'End of Localization content
  38. '-------------------------------------------------------------------------------------------------
  39. 'serve the HTML content along with client side validations
  40. Call ServePage()
  41. '------------------------------------------------------------------------------------
  42. 'Function name :ServeContent
  43. 'Description :serves the HTML content along with client side validations
  44. 'Input Variables :None
  45. 'Output Variables :None
  46. 'Returns :None
  47. 'Global Variables :L_*
  48. '------------------------------------------------------------------------------------
  49. Function ServeContent()
  50. %>
  51. <script language="JavaScript">
  52. function ValidatePage()
  53. {
  54. return true;
  55. }
  56. function Init()
  57. {
  58. return true;
  59. }
  60. function SetData()
  61. {
  62. return true;
  63. }
  64. </script>
  65. <%
  66. If ( IsIE() AND InStr( Request.ServerVariables("HTTP_USER_AGENT"), "Windows")) Then
  67. %>
  68. <script language="VBScript">
  69. 'called when first time new window is loaded
  70. Sub window_onLoad()
  71. on error resume next
  72. Err.Clear
  73. Dim srvName 'holds server name
  74. If not "<%Response.Write(GetServerName())%>" = "" Then
  75. srvName = "<%Response.Write(GetServerName()) %>"
  76. Else
  77. srvName = Document.location.hostname
  78. End If
  79. Dim objMsTsc 'holds Terminal Services object
  80. objMsTsc = Document.getElementById("MsTsc")
  81. If ( Err.Number = 0 ) Then
  82. document.getElementById("MsTsc").Server = srvName
  83. Document.getElementById("MsTsc").UserName = "<%=GetUserName()%>"
  84. If Document.getElementById("MsTsc").SecuredSettingsEnabled Then
  85. Document.getElementById("MsTsc").SecuredSettings.StartProgram = "ntbackup.exe"
  86. Document.getElementById("MsTsc").SecuredSettings.WorkDir = "%homedrive%%homepath%"
  87. Else
  88. msgbox "<%Response.Write(Server.HTMLEncode(SA_EscapeQuotes(L_UNABLETOACCESSBROWSER_ERRORMESSAGE))) %>"
  89. End If
  90. Document.getElementById("MsTsc").Connect()
  91. End If
  92. End Sub
  93. 'called when terminal services is disconnected
  94. sub MsTsc_OnDisconnected(disconnectCode)
  95. 'Document.getElementById("MsTsc").Disconnect()
  96. if not disconnectCode = 2 then
  97. 'msgbox "<%Response.Write(Server.HTMLEncode(SA_EscapeQuotes(L_BACKUP_SERVERCONNECTIONFAILED_ERRORMESSAGE))) %>" & MsTsc.Server
  98. msgbox "<%Response.Write(L_ERRMSG_PROMPT) %>", , "<%Response.Write(L_ERRMSG_TITLE) %>"
  99. end if
  100. Window.close()
  101. end sub
  102. </script>
  103. <%
  104. End If
  105. %>
  106. <center>
  107. <table>
  108. <tr>
  109. <td align=center>
  110. <%
  111. If ( IsIE() AND InStr( Request.ServerVariables("HTTP_USER_AGENT"), "Windows")) Then
  112. %>
  113. <OBJECT language="vbscript" ID="MsTsc"
  114. CLASSID="CLSID:9059f30f-4eb1-4bd2-9fdc-36f43a218f4a"
  115. codebase="<%=SAI_GetTSClientCodeBase()%>"
  116. <%
  117. Dim resWidth ' to hold width of the new terminal services window
  118. resWidth = Request.QueryString("rW")
  119. If resWidth < 200 or resWidth > 1600 Then
  120. resWidth = 800
  121. End If
  122. Response.Write("WIDTH="+CStr(resWidth)+" ")
  123. Dim resHeight ' to hold height of the new terminal services window
  124. resHeight = Request.QueryString("rH")
  125. If resHeight < 200 or resHeight > 1200 Then
  126. resHeight = 600
  127. End If
  128. Response.Write("HEIGHT="+CStr(resHeight) + " " )
  129. %>
  130. </OBJECT>
  131. <%
  132. End If
  133. %>
  134. </td>
  135. </tr>
  136. </table>
  137. </center>
  138. <%
  139. End Function
  140. %>
  141. <%
  142. '------------------------------------------------------------------------------------
  143. 'Subroutine name :ServePage
  144. 'Description :serves the HTML content
  145. 'Input Variables :None
  146. 'Output Variables :None
  147. 'Returns :None
  148. 'Global Variables :L_*
  149. '------------------------------------------------------------------------------------
  150. Sub ServePage()
  151. Err.Clear
  152. On Error Resume Next
  153. %>
  154. <HTML>
  155. <HEAD>
  156. <meta http-equiv="Content-Type" content="text/html; charset=<%=GetCharSet()%>">
  157. <TITLE><%=L_BACKUPTITLE_TEXT%></TITLE>
  158. <LINK REL="stylesheet" TYPE="text/css" HREF="<%=m_VirtualRoot%>style/mssastyles.css">
  159. <SCRIPT LANGUAGE="JavaScript" SRC="<%=m_VirtualRoot%>sh_page.js"></SCRIPT>
  160. </HEAD>
  161. <BODY MARGINWIDTH ="0" MARGINHEIGHT="0" onDragDrop="return false;" TOPMARGIN="0" LEFTMARGIN="0" oncontextmenu="//return false;">
  162. <%
  163. 'For XP pro (XPE), we display help msg for how to manully open up the ntbackup.exe
  164. 'since launching a app from Termial Service is not supported in XP pro.
  165. If CONST_OSNAME_XPE = GetServerOSName() Then
  166. Response.Write L_BACKUP_HELP_MESSAGE
  167. End If
  168. Dim bIsSupported 'whether the browser is installed on Windows Clients
  169. bIsSupported = false 'initialize to false
  170. '
  171. ' The Terminal Server ActiveX control is only supported on Windows Clients
  172. ' running Internet Explorer.
  173. '
  174. If IsIE() Then
  175. If InStr( Request.ServerVariables("HTTP_USER_AGENT"), "Windows") Then
  176. bIsSupported = true
  177. End If
  178. End If
  179. 'if IE installed on Windows Clients, serve the HTML content
  180. If ( bIsSupported ) Then
  181. ServeContent()
  182. Else
  183. Response.Write("<br><blockquote>")
  184. Response.Write("<H2>"+L_BACKUP_WINIECLIENT_ERRORMESSAGE+"</H2>")
  185. Response.Write("</blockquote>")
  186. End If
  187. %>
  188. </BODY>
  189. </HTML>
  190. <%
  191. End Sub
  192. '------------------------------------------------------------------------------------
  193. 'Function name :GetUserName
  194. 'Description :gets the user name
  195. 'Input Variables :None
  196. 'Output Variables :None
  197. 'Returns :login user name
  198. 'Global Variables :None
  199. '------------------------------------------------------------------------------------
  200. Function GetUserName()
  201. Dim domainAndUser 'holds string containing DOMAIN\USER
  202. Dim loginUser 'holds LOGIN user
  203. loginUser = Request.ServerVariables("LOGON_USER")
  204. domainAndUser = Split(loginUser, "\")
  205. If IsArray(domainAndUser) Then
  206. GetUserName = domainAndUser(UBound(domainAndUser))
  207. Else
  208. GetUserName = loginUser
  209. End If
  210. End Function
  211. %>