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.

290 lines
19 KiB

  1. ��<HTML>
  2. <!-- Copyright (c) Microsoft Corporation. All rights reserved.-->
  3. <HEAD>
  4. <TITLE>Static Ip Setting Page</TITLE>
  5. <SCRIPT LANGUAGE="VBScript">
  6. <!--
  7. Option Explicit
  8. 'Windows constants for key codes
  9. Public Const RightArrow = 39
  10. Public Const LeftArrow = 37
  11. Public Const EnterKey = 13
  12. Public Const EscapeKey = 27
  13. Public Const UpArrow = 38
  14. Public Const DownArrow = 40
  15. 'Timer for idle timeout
  16. Dim iIdleTimeOut
  17. 'Text for wait information
  18. Dim strWaitText
  19. 'Flag for errors
  20. Dim bInErrorMode
  21. 'Flag for accessing netcfg component
  22. Dim bAccessDenied
  23. 'Ip address error text
  24. Dim strIpAddressInvalidText
  25. 'General error text for the task
  26. Dim strStaticIpErrorText
  27. '----------------------------------------------------------------------------
  28. ' Function: Window_OnLoad
  29. ' Description: Initialization routine for the page
  30. ' Input Variables: None
  31. ' Output Variables: None
  32. ' Return Values: None
  33. ' Global Variables: iIdleTimeOut,strWaitText,bInErrorMode,strIpAddressInvalidText
  34. '----------------------------------------------------------------------------
  35. Sub Window_OnLoad()
  36. 'Localization manager object
  37. Dim objLocMgr
  38. 'Replacement strings
  39. Dim varReplacementStrings
  40. 'Resource ID for wait information text
  41. Const WAIT_TEXT = "&H40020012"
  42. 'Resource ID for Ip address error text
  43. Const IPADDRESS_ERROR_TEXT = "&H4002000A"
  44. 'Resource ID for task error text
  45. Const STATICIP_ERROR_TEXT = "&H40020007"
  46. 'SaHelper component object
  47. Dim objSaHelper
  48. 'Current static ip address
  49. Dim strStaticIP
  50. 'Current subnet mask
  51. Dim strSubnetMask
  52. 'Current default gateway
  53. Dim strDefaultGateway
  54. On Error Resume Next
  55. Err.Clear
  56. bInErrorMode = false
  57. bAccessDenied = false
  58. 'Create the localization manager
  59. Set objLocMgr = CreateObject("ServerAppliance.LocalizationManager")
  60. If Err.number = 0 Then
  61. 'Get the strings
  62. strWaitText = objLocMgr.GetString("salocaluimsg.dll",WAIT_TEXT,varReplacementStrings)
  63. strIpAddressInvalidText = objLocMgr.GetString("salocaluimsg.dll",IPADDRESS_ERROR_TEXT,varReplacementStrings)
  64. strStaticIpErrorText = objLocMgr.GetString("salocaluimsg.dll",STATICIP_ERROR_TEXT,varReplacementStrings)
  65. Set objLocMgr = Nothing
  66. End If
  67. Err.Clear
  68. InformationText.innerText = strWaitText
  69. 'get the current configuration
  70. Set objSaHelper = CreateObject("ServerAppliance.SAHelper")
  71. If Err.number = 0 Then
  72. strStaticIP = objSaHelper.IpAddress
  73. If Err.number = 0 Then
  74. StaticIpEntry.IpAddress = strStaticIP
  75. End If
  76. Err.Clear
  77. strSubnetMask = objSaHelper.SubnetMask
  78. If Err.number = 0 Then
  79. StaticIpEntry.SubnetMask = strSubnetMask
  80. End If
  81. Err.Clear
  82. strDefaultGateway = objSaHelper.DefaultGateway
  83. If Err.number = 0 Then
  84. StaticIpEntry.Gateway = strDefaultGateway
  85. End If
  86. Err.Clear
  87. Set objSaHelper = Nothing
  88. End If
  89. StaticIpEntry.focus
  90. 'start the timer for idle timeout
  91. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  92. On Error Resume Next
  93. Err.Clear
  94. 'set the key codes for the page
  95. Dim objKeypad
  96. Set objKeypad = CreateObject("Ldm.SAKeypadController")
  97. If Err.number = 0 Then
  98. objKeypad.Setkey 0,UpArrow,TRUE
  99. objKeypad.Setkey 1,DownArrow,FALSE
  100. objKeypad.Setkey 2,LeftArrow,FALSE
  101. objKeypad.Setkey 3,RightArrow,FALSE
  102. objKeypad.Setkey 4,EscapeKey,FALSE
  103. objKeypad.Setkey 5,EnterKey,FALSE
  104. Set objKeypad = Nothing
  105. End If
  106. End Sub
  107. '----------------------------------------------------------------------------
  108. ' Function: IdleHandler
  109. ' Description: Goes back to main page when timeout expires
  110. ' Input Variables: None
  111. ' Output Variables: None
  112. ' Return Values: None
  113. ' Global Variables: None
  114. '----------------------------------------------------------------------------
  115. Sub IdleHandler()
  116. window.history.go(-3)
  117. End Sub
  118. '----------------------------------------------------------------------------
  119. ' Function: StaticIpEntry_OperationCanceled
  120. ' Description: Handles escape key press for static ip entry control
  121. ' Goes back to network page
  122. ' Input Variables: None
  123. ' Output Variables: None
  124. ' Return Values: None
  125. ' Global Variables: None
  126. '----------------------------------------------------------------------------
  127. Sub StaticIpEntry_OperationCanceled()
  128. If bInErrorMode = false Then
  129. window.history.go(-1)
  130. Else
  131. bInErrorMode = false
  132. End If
  133. End Sub
  134. '----------------------------------------------------------------------------
  135. ' Function: StaticIpEntry_KeyPressed
  136. ' Description: Handles any key press for static ip entry control
  137. ' Resets the idle timeout timer
  138. ' Input Variables: None
  139. ' Output Variables: None
  140. ' Return Values: None
  141. ' Global Variables: None
  142. '----------------------------------------------------------------------------
  143. Sub StaticIpEntry_KeyPressed()
  144. window.clearTimeOut(iIdleTimeOut)
  145. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  146. End Sub
  147. '----------------------------------------------------------------------------
  148. ' Function: StaticIpEntry_StaticIpEntered
  149. ' Description: Handles enter key press for static ip entry control
  150. ' Sets the static ip and displays the result
  151. ' Input Variables: None
  152. ' Output Variables: None
  153. ' Return Values: None
  154. ' Global Variables: None
  155. '----------------------------------------------------------------------------
  156. Sub StaticIpEntry_StaticIpEntered()
  157. 'SaHelper object pointer
  158. Dim objSaHelper
  159. On Error Resume Next
  160. Err.Clear
  161. If bInErrorMode = false and bAccessDenied = false Then
  162. 'Display the wait text
  163. InformationText.style.display = ""
  164. 'Hide the data entry control
  165. StaticIpEntry.style.display ="none"
  166. Set objSaHelper = CreateObject("ServerAppliance.SAHelper")
  167. 'If object is successfully created
  168. If Err.Number = 0 Then
  169. objSaHelper.SetStaticIp StaticIpEntry.IpAddress, StaticIpEntry.SubnetMask, StaticIpEntry.Gateway
  170. Set objSaHelper = Nothing
  171. End If
  172. 'Ip address successfully set
  173. If Err.Number = 0 Then
  174. window.history.go(-1)
  175. 'Error accessing the netcfg component
  176. ElseIf Err.Number = 70 Then
  177. bAccessDenied = true
  178. InformationText.innerText = strStaticIpErrorText
  179. 'Something failed, display error information
  180. Else
  181. InformationText.innerText = strIpAddressInvalidText
  182. bInErrorMode = true
  183. End If
  184. ElseIf bAccessDenied = true Then
  185. window.history.go(-1)
  186. Else
  187. bInErrorMode = false
  188. End If
  189. End Sub
  190. '----------------------------------------------------------------------------
  191. ' Function: KeyDown
  192. ' Description: Handles key presses
  193. ' Input Variables: None
  194. ' Output Variables: None
  195. ' Return Values: None
  196. ' Global Variables: None
  197. '----------------------------------------------------------------------------
  198. Sub KeyDown()
  199. 'clear the timeout and restart it
  200. window.clearTimeOut(iIdleTimeOut)
  201. iIdleTimeOut = window.SetTimeOut("IdleHandler()",300000)
  202. 'If escape key is hit, go back to tasks page
  203. If window.event.keycode = EscapeKey or window.event.keycode = EnterKey Then
  204. StaticIpEntry.style.display = ""
  205. StaticIpEntry.focus
  206. InformationText.style.display = "none"
  207. InformationText.innerText = strWaitText
  208. End If
  209. End Sub
  210. -->
  211. </SCRIPT>
  212. </HEAD>
  213. <BODY RIGHTMARGIN=0 LEFTMARGIN=0 OnKeydown="KeyDown">
  214. <OBJECT STYLE="position:absolute; top:0; left=0; WIDTH=128; HEIGHT=64;"
  215. ID="StaticIpEntry" CLASSID="CLSID:D8A69FA0-25FE-4B9C-BBCE-81D6EBE2FDC0">
  216. </OBJECT>
  217. <A ID="InformationText"
  218. STYLE="position:absolute; top:0; left:0; font-size:10; font-family=arial; display=none;" >
  219. </A>
  220. </BODY>
  221. </HTML>