PageRenderTime 39ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 0ms

/WebsitePanel/Sources/WebsitePanel.WebPortal/DesktopModules/WebsitePanel/VPS/RemoteDesktop/Connect.aspx

#
ASP.NET | 231 lines | 21 code | 5 blank | 205 comment | 0 complexity | d9ed66f30f044b5281e59cff405e269c MD5 | raw file
Possible License(s): BSD-3-Clause, Unlicense, MPL-2.0-no-copyleft-exception, LGPL-2.0
  1. <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Connect.aspx.cs" Inherits="WebsitePanel.Portal.VPS.RemoteDesktop.Connect" %>
  2. <!DOCTYPE html>
  3. <html>
  4. <head runat="server">
  5. <title>
  6. <asp:Literal ID="litServerName" runat="server"></asp:Literal>
  7. <asp:Localize ID="locTitle" runat="server" meta:resourcekey="locTitle" Text="Remote Desktop Web Connection"></asp:Localize></title>
  8. </head>
  9. <body style="margin:0;">
  10. <script language="vbscript" type="text/vbscript">
  11. <!--
  12. const L_FullScreenWarn1_Text = "Your current security settings do not allow automatically switching to fullscreen mode."
  13. const L_FullScreenWarn2_Text = "You can use ctrl-alt-pause to toggle your remote desktop session to fullscreen mode"
  14. const L_FullScreenTitle_Text = "Remote Desktop Web Connection "
  15. const L_ErrMsg_Text = "Error connecting to remote computer: "
  16. const L_PlatformCheck_ErrorMessage = "The Remote Desktop Web connection ActiveX control can only run in the 32-bit version of Internet Explorer."
  17. ' error messages
  18. const L_DisconnectedCaption_ErrorMessage = "Remote Desktop Disconnected"
  19. const L_ErrConnectCallFailed_ErrorMessage = "An error occurred when the client attempted to connect to the remote computer. Check your system memory and then try the connection again."
  20. const L_DisconnectRemoteByServer_ErrorMessage = "The remote computer has ended the connection."
  21. const L_LowMemory_ErrorMessage = "The local computer is low on memory. Close some programs, and then connect to the remote computer again."
  22. const L_SecurityErr_ErrorMessage = "Because of a security error, the client could not connect to the remote computer. Verify that you are logged on to the network, and then try connecting again."
  23. const L_BadServerName_ErrorMessage = "The specified remote computer could not be found. Verify that you have typed the correct computer name or IP address, and then try connecting again."
  24. const L_ConnectFailedProtocol_ErrorMessage = "Because of a protocol error, the client could not connect to the remote computer. Please try connecting to the remote computer again. If the client still fails to connect, contact your network administrator."
  25. const L_CannotLoopBackConnect_ErrorMessage = "The client could not connect. You cannot connect to the console from a console session of the same computer."
  26. const L_NetworkErr_ErrorMessage = "The connection was ended because of a network error. Please try connecting to the remote computer again."
  27. const L_InternalErr_ErrorMessage = "An internal error has occurred."
  28. const L_NotResponding_ErrorMessage = "The client could not connect to the remote computer. Remote connections might not be enabled or the computer might be too busy to accept new connections.It is also possible that network problems are preventing your connection.Please try connecting again later. If the problem continues to occur, contact your administrator."
  29. const L_VersionMismatch_ErrorMessage = "Client and server versions do not match. Please upgrade your client software and then try connecting again."
  30. const L_EncryptionError_ErrorMessage = "Because of an error in data encryption, this session will end. Please try connecting to the remote computer again."
  31. const L_ProtocolErr_ErrorMessage = "Because of a protocol error, this session will be disconnected. Please try connecting to the remote computer again."
  32. const L_IllegalServerName_ErrorMessage = "The specified computer name contains invalid characters. Please verify the name and try again."
  33. const L_ConnectionTimeout_ErrorMessage = "The remote connection has timed out. Please try connecting to the remote computer again."
  34. const L_DisconnectIdleTimeout_ErrorMessage = "The remote session was ended because the idle timeout limit was reached. This limit is set by the server administrator or by network policies."
  35. const L_DisconnectLogonTimeout_ErrorMessage ="The remote session ended because the total logon time limit was reached. This limit is set by the server administrator or by network policies."
  36. const L_ProtocolErrWITHCODE_ErrorMessage = "Client disconnected due to internal protocol error: "
  37. const L_LicensingTimeout_ErrorMessage = "A licensing error occurred while the client was attempting to connect (Licensing timed out).Please try connecting to the remote computer again."
  38. const L_LicensingNegotFailed_ErrorMessage = "The remote computer disconnected the session because of an error in the licensing protocol.Please try connecting to the remote computer again or contact your server administrator."
  39. const L_DisconnectRemoteByServerTool_ErrorMessage = "The remote session to the remote computer was ended by means of an administration tool.Your administrator might have ended your connection."
  40. const L_LogoffRemoteByServer_ErrorMessage = "The remote session was disconnected because your session was logged off at the remote computer.Your administrator or another user might have ended your connection."
  41. const L_DisconnectByOtherConnection_ErrorMessage = "The remote session was disconnected because another user has connected to the session."
  42. const L_ConnectionBroken_ErrorMessage = "The connection to the remote computer was broken. This may have been caused by a network error.Please try connecting to the remote computer again."
  43. const L_ServerOutOfMemory_ErrorMessage = "The connection was disconnected because the remote computer is low on memory."
  44. const L_LicenseInternal_ErrorMessage = "The remote session was disconnected because there was an internal error in the remote computer's licensing protocol."
  45. const L_NoLicenseServer_ErrorMessage = "The remote session was disconnected because there are no Terminal Server License Servers available to provide a license.Please contact the server administrator."
  46. const L_NoLicense_ErrorMessage = "The remote session was disconnected because there are no Terminal Server client access licenses available for this computer.Please contact the server administrator."
  47. const L_LicenseBadClientMsg_ErrorMessage = "The remote session was disconnected because the remote computer received an invalid licensing message from this computer."
  48. const L_LicenseHwidDoesntMatch_ErrorMessage = "The remote session was disconnected because the Terminal Server client access license stored on this computer has been modified."
  49. const L_BadClientLicense_ErrorMessage = "The remote session was disconnected because the Terminal Server client access license stored on this computer is in an invalid format."
  50. const L_LicenseCantFinishProtocol_ErrorMessage = "The remote session was disconnected because there were network problems during the licensing protocol.Please try connecting to the remote computer again."
  51. const L_LicenseClientEndedProtocol_ErrorMessage = "The remote session was disconnected because the client prematurely ended the licensing protocol."
  52. const L_LicenseBadClientEncryption_ErrorMessage = "The remote session was disconnected because a licensing message was incorrectly encrypted."
  53. const L_CantUpgradeLicense_ErrorMessage = "The remote session was disconnected because the local computer's client access license could not be upgraded or renewed.Please contact the server administrator."
  54. const L_LicenseNoRemoteConnections_ErrorMessage = "The remote session was disconnected because the remote computer is not licensed to accept remote connections.Please contact the server administrator."
  55. const L_DecompressionFailed_ErrorMessage = "The remote session was disconnected because of a decompression failure at the client side. Please try connecting to the remote computer again."
  56. const L_ServerDeniedConnection_ErrorMessage ="The client could not establish a connection to the remote computer.The most likely causes for this error are:1) Remote connections might not be enabled at the remote computer.2) The maximum number of connections was exceeded at the remote computer.3) A network error occurred while establishing the connection."
  57. resWidth = 0
  58. resHeight = 0
  59. resolution = "<asp:Literal id="resolution" runat="server"/>"
  60. serverName = "<asp:Literal id="serverName" runat="server"/>"
  61. username = "<asp:Literal id="username" runat="server"/>"
  62. domain = ""
  63. password = "<asp:Literal id="password" runat="server"/>"
  64. sub OnControlLoad
  65. set Control = Document.getElementById("MsRdpClient")
  66. if Not Control is Nothing then
  67. if Control.readyState = 4 then
  68. BtnConnect()
  69. end if
  70. end if
  71. end sub
  72. sub BtnConnect
  73. if not LCase(Navigator.CpuClass) = "x86" then
  74. msgbox L_PlatformCheck_ErrorMessage
  75. end if
  76. 'Resolution
  77. MsRdpClient.FullScreen = FALSE
  78. select case resolution
  79. case "1"
  80. MsRdpClient.FullScreen = TRUE
  81. resWidth = screen.width
  82. resHeight = screen.height
  83. case "2"
  84. resWidth = "800"
  85. resHeight = "600"
  86. case "3"
  87. resWidth = "1024"
  88. resHeight = "768"
  89. case "4"
  90. resWidth = "1280"
  91. resHeight = "1024"
  92. end select
  93. 'ResizeWindow resWidth, resHeight
  94. MsRdpClient.server = serverName
  95. MsRdpClient.UserName = username
  96. MsRdpClient.Domain = domain
  97. MsRdpClient.AdvancedSettings2.ClearTextPassword = password
  98. MsRdpClient.DesktopWidth = resWidth
  99. MsRdpClient.DesktopHeight = resHeight
  100. MsRdpClient.Width = resWidth
  101. MsRdpClient.Height = resHeight
  102. 'Device redirection options
  103. MsRdpClient.AdvancedSettings2.RedirectDrives = FALSE
  104. MsRdpClient.AdvancedSettings2.RedirectPrinters = FALSE
  105. MsRdpClient.AdvancedSettings2.RedirectPorts = FALSE
  106. MsRdpClient.AdvancedSettings2.RedirectSmartCards = FALSE
  107. 'FullScreen title
  108. MsRdpClient.FullScreenTitle = L_FullScreenTitle_Text & "(" & serverName & ")"
  109. 'Connect
  110. MsRdpClient.Connect
  111. end sub
  112. sub MsRdpClient_OnConnected()
  113. ' nothing to do
  114. end sub
  115. sub MsRdpClient_OnDisconnected(disconnectCode)
  116. extendedDiscReason = MsRdpClient.ExtendedDisconnectReason
  117. majorDiscReason = disconnectCode And &hFF
  118. if (disconnectCode = &hB08 or majorDiscReason = 2 or majorDiscReason = 1) and not (extendedDiscReason = 5) then
  119. window.close()
  120. exit sub
  121. end if
  122. errMsgText = L_DisconnectRemoteByServer_ErrorMessage
  123. if not extendedDiscReason = 0 then
  124. 'Use the extended disconnect code
  125. select case extendedDiscReason
  126. case 0 errMsgText = ""
  127. case 1 errMsgText = L_DisconnectRemoteByServerTool_ErrorMessage
  128. case 2 errMsgText = L_LogoffRemoteByServer_ErrorMessage
  129. case 3 errMsgText = L_DisconnectIdleTimeout_ErrorMessage
  130. case 4 errMsgText = L_DisconnectLogonTimeout_ErrorMessage
  131. case 5 errMsgText = L_DisconnectByOtherConnection_ErrorMessage
  132. case 6 errMsgText = L_ServerOutOfMemory_ErrorMessage
  133. case 7 errMsgText = L_ServerDeniedConnection_ErrorMessage
  134. case 256 errMsgText = L_LicenseInternal_ErrorMessage
  135. case 257 errMsgText = L_NoLicenseServer_ErrorMessage
  136. case 258 errMsgText = L_NoLicense_ErrorMessage
  137. case 259 errMsgText = L_LicenseBadClientMsg_ErrorMessage
  138. case 260 errMsgText = L_LicenseHwidDoesntMatch_ErrorMessage
  139. case 261 errMsgText = L_BadClientLicense_ErrorMessage
  140. case 262 errMsgText = L_LicenseCantFinishProtocol_ErrorMessage
  141. case 263 errMsgText = L_LicenseClientEndedProtocol_ErrorMessage
  142. case 264 errMsgText = L_LicenseBadClientEncryption_ErrorMessage
  143. case 265 errMsgText = L_CantUpgradeLicense_ErrorMessage
  144. case 266 errMsgText = L_LicenseNoRemoteConnections_ErrorMessage
  145. case else errMsgText = L_ErrMsg_Text
  146. end select
  147. if extendedDiscReason > 4096 then
  148. errMsgText = L_ProtocolErrWITHCODE_ErrorMessage & errMsgText
  149. end if
  150. else
  151. ' no extended error information, use the disconnect code
  152. select case disconnectCode
  153. case 0 errMsgText = L_ErrMsg_Text
  154. case 1 errMsgText = L_ErrMsg_Text
  155. case 2 errMsgText = L_ErrMsg_Text
  156. case 260 errMsgText = L_BadServerName_ErrorMessage
  157. case 262 errMsgText = L_LowMemory_ErrorMessage
  158. case 264 errMsgText = L_ConnectionTimeout_ErrorMessage
  159. case 516 errMsgText = L_NotResponding_ErrorMessage
  160. case 518 errMsgText = L_LowMemory_ErrorMessage
  161. case 520 errMsgText = L_BadServerName_ErrorMessage
  162. case 772 errMsgText = L_NetworkErr_ErrorMessage
  163. case 774 errMsgText = L_LowMemory_ErrorMessage
  164. case 776 errMsgText = L_BadServerName_ErrorMessage
  165. case 1028 errMsgText = L_NetworkErr_ErrorMessage
  166. case 1030 errMsgText = L_SecurityErr_ErrorMessage
  167. case 1032 errMsgText = L_IllegalServerName_ErrorMessage
  168. case 1286 errMsgText = L_EncryptionError_ErrorMessage
  169. case 1288 errMsgText = L_BadServerName_ErrorMessage
  170. case 1540 errMsgText = L_BadServerName_ErrorMessage
  171. case 1542 errMsgText = L_SecurityErr_ErrorMessage
  172. case 1544 errMsgText = L_LowMemory_ErrorMessage
  173. case 1796 errMsgText = L_NotResponding_ErrorMessage
  174. case 1798 errMsgText = L_SecurityErr_ErrorMessage
  175. case 1800 errMsgText = L_CannotLoopBackConnect_ErrorMessage
  176. case 2052 errMsgText = L_BadServerName_ErrorMessage
  177. case 2056 errMsgText = L_LicensingNegotFailed_ErrorMessage
  178. case 2310 errMsgText = L_SecurityErr_ErrorMessage
  179. case 2566 errMsgText = L_SecurityErr_ErrorMessage
  180. case 2822 errMsgText = L_EncryptionError_ErrorMessage
  181. case 3078 errMsgText = L_EncryptionError_ErrorMessage
  182. case 3080 errMsgText = L_DecompressionFailed_ErrorMessage
  183. case 3334 errMsgText = L_ProtocolErr_ErrorMessage
  184. case 10500 errMsgText = L_ProtocolErr_ErrorMessage
  185. case else errMsgText = L_InternalErr_ErrorMessage
  186. end select
  187. end if
  188. msgbox errMsgText,0,L_DisconnectedCaption_ErrorMessage
  189. window.close()
  190. end sub
  191. -->
  192. </script>
  193. <object language="vbscript" id="MsRdpClient"
  194. onreadystatechange="OnControlLoad"
  195. classid="CLSID:9059f30f-4eb1-4bd2-9fdc-36f43a218f4a"
  196. codebase="msrdp.cab#version=5,1,2600,2180"
  197. width="100" height="100">
  198. </object>
  199. <form id="AspForm" runat="server">
  200. </form>
  201. </body>
  202. </html>