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.

275 lines
9.2 KiB

  1. <% @Language=VbScript%>
  2. <% Option Explicit %>
  3. <% '----------------------------------------------------------------------------
  4. ' nicRename_prop.asp: change the connecion name
  5. '
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '
  8. ' Date Description
  9. '28-Feb-01 Creation date
  10. '09-Mar-01 Modified date
  11. '-----------------------------------------------------------------------------
  12. %>
  13. <!-- #include virtual="/admin/inc_framework.asp"--->
  14. <!-- #include file="loc_nicspecific.asp" -->
  15. <!-- #include file="inc_network.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Global Variables
  19. '-------------------------------------------------------------------------
  20. Dim G_objService 'Object to SWBEM service
  21. Dim G_strConnName 'Connection name
  22. Dim G_intAdapterID 'Adapter ID
  23. Dim page 'Variable that receives the output page object when
  24. 'creating a page
  25. Dim rc 'Return value for CreatePage
  26. 'Create property page
  27. rc=SA_CreatePage(L_RENAMETASKTITLE_TEXT,"",PT_PROPERTY,page)
  28. 'Serve the page
  29. If(rc=0) then
  30. SA_ShowPage(Page)
  31. End if
  32. '-------------------------------------------------------------------------
  33. 'Function: OnInitPage()
  34. 'Description: Called to signal first time processing for this page.
  35. ' Use this method to do first time initialization tasks
  36. 'Input Variables: PageIn,EventArg
  37. 'Output Variables: PageIn,EventArg
  38. 'Returns: True/False
  39. 'Global Variables: None
  40. '-------------------------------------------------------------------------
  41. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  42. G_strConnName = GetConnectionName() ' Gets the connection name
  43. OnInitPage = True
  44. End Function
  45. '-------------------------------------------------------------------------
  46. 'Function: OnServePropertyPage()
  47. 'Description: Called when the page needs to be served.Use this
  48. ' method to serve content
  49. 'Input Variables: PageIn,EventArg
  50. 'Output Variables: PageIn,EventArg
  51. 'Returns: True/False
  52. 'Global Variables: G_*,L_*
  53. '-------------------------------------------------------------------------
  54. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  55. Call ServeCommonJavaScript()
  56. %>
  57. <TABLE WIDTH=518 VALIGN=CENTER ALIGN=left BORDER=0 CELLSPACING=0 CELLPADDING=2 class="Tasksbody">
  58. <TR>
  59. <td nowrap COLSPAN=4><B><%=G_strConnName%></B></td>
  60. </TR>
  61. <TR>
  62. <td COLSPAN=4>&nbsp;</td>
  63. </TR>
  64. <TR>
  65. <TD width=25% NOWRAP>
  66. <%=L_CONNNAME_TEXT%>
  67. </TD>
  68. <TD NOWRAP>
  69. <input NAME="txtConnectionName" TYPE="text" SIZE="30" maxlength=284 VALUE="<%=G_strConnName%>">
  70. </TD>
  71. </TR>
  72. </TABLE>
  73. <input type=hidden name=hdnAdapterID value="<%=server.HTMLEncode(G_intAdapterID)%>">
  74. <input type=hidden name=hdnConnectionName value="<%=server.HTMLEncode(G_strConnName)%>">
  75. <%
  76. OnServePropertyPage = True
  77. End Function
  78. '-------------------------------------------------------------------------
  79. 'Function: OnPostBackPage()
  80. 'Description: Called to signal that the page has been posted-back.
  81. 'Input Variables: PageIn,EventArg
  82. 'Output Variables: PageIn,EventArg
  83. 'Returns: True/False
  84. 'Global Variables: None
  85. '-------------------------------------------------------------------------
  86. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  87. G_strConnName = Request.Form("hdnConnectionName")
  88. OnPostBackPage = True
  89. End Function
  90. '-------------------------------------------------------------------------
  91. 'Function: OnSubmitPage()
  92. 'Description: Called when the page has been submitted for processing.
  93. ' Use this method to process the submit request.
  94. 'Input Variables: PageIn,EventArg
  95. 'Output Variables: PageIn,EventArg
  96. 'Returns: True/False
  97. 'Global Variables: None
  98. '-------------------------------------------------------------------------
  99. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  100. Dim strConnName 'to hold connection name
  101. Dim strAdapterID 'to hold adapter ID
  102. strConnName = Request.Form("hdnConnectionName")
  103. strAdapterID = Request.Form("hdnAdapterID")
  104. OnSubmitPage = SetConnectionName(strAdapterID,strConnName)
  105. End Function
  106. '-------------------------------------------------------------------------
  107. 'Function: OnClosePage()
  108. 'Description: Called when the page is about closed.Use this method
  109. ' to perform clean-up processing
  110. 'Input Variables: PageIn,EventArg
  111. 'Output Variables: PageIn,EventArg
  112. 'Returns: True/False
  113. 'Global Variables: None
  114. '-------------------------------------------------------------------------
  115. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  116. OnClosePage = TRUE
  117. End Function
  118. '-------------------------------------------------------------------------
  119. 'Function: ServeCommonJavaScript
  120. 'Description: Serves in initialiging the values,setting the form
  121. ' data and validating the form values
  122. 'Input Variables: None
  123. 'Output Variables: None
  124. 'Returns: True/False
  125. 'Global Variables: None
  126. '-------------------------------------------------------------------------
  127. Function ServeCommonJavaScript()
  128. Err.Clear
  129. On Error Resume Next
  130. %>
  131. <script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  132. </script>
  133. <script language="JavaScript">
  134. //
  135. // Microsoft Server Appliance Web Framework Support Functions
  136. // Copyright (c) Microsoft Corporation. All rights reserved.
  137. //
  138. // Init Function
  139. // -----------
  140. // This function is called by the Web Framework to allow the page
  141. // to perform first time initialization.
  142. //
  143. // This function must be included or a javascript runtime error will occur.
  144. //
  145. function Init()
  146. {
  147. return true;
  148. }
  149. // ValidatePage Function
  150. // ------------------
  151. // This function is called by the Web Framework as part of the
  152. // submit processing. Use this function to validate user input. Returning
  153. // false will cause the submit to abort.
  154. //
  155. // This function must be included or a javascript runtime error will occur.
  156. //
  157. // Returns: True if the page is OK, false if error(s) exist.
  158. function ValidatePage()
  159. {
  160. var strCon = document.frmTask.txtConnectionName.value;
  161. if(strCon=="")
  162. {
  163. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDCONNAME_ERRORMESSAGE))%>");
  164. return false;
  165. }
  166. document.frmTask.hdnConnectionName.value = strCon;
  167. return true;
  168. }
  169. // SetData Function
  170. // --------------
  171. // This function is called by the Web Framework and is called
  172. // only if ValidatePage returned a success (true) code. Typically you would
  173. // modify hidden form fields at this point.
  174. //
  175. // This function must be included or a javascript runtime error will occur.
  176. //
  177. function SetData()
  178. {
  179. return true;
  180. }
  181. </script>
  182. <%
  183. End Function
  184. '-------------------------------------------------------------------------
  185. 'Function: GetConnectionName
  186. 'Description: gets the connection name
  187. 'Input Variables: None
  188. 'Output Variables: None
  189. 'Returns: None
  190. 'Global Variables: G_strConnName, G_intAdapterID
  191. '-------------------------------------------------------------------------
  192. Function GetConnectionName()
  193. Dim itemCount 'holds the item count
  194. Dim x 'holds count for loop
  195. Dim itemKey 'holds the item selected from OTS
  196. itemCount = OTS_GetTableSelectionCount("")
  197. For x = 1 to itemCount
  198. If ( OTS_GetTableSelection("", x, itemKey) ) Then
  199. G_intAdapterID = itemKey
  200. GetConnectionName = GetNicName(itemKey) 'gets the NIC card name
  201. End If
  202. Next
  203. End Function
  204. '-------------------------------------------------------------------------
  205. 'Function: SetConnectionName
  206. 'Description: sets the connection name
  207. 'Input Variables: Adapter ID,Connection Name
  208. 'Output Variables: None
  209. 'Returns: Boolean
  210. 'Global Variables: None
  211. '-------------------------------------------------------------------------
  212. Function SetConnectionName(strAdapterID,strConnName)
  213. Err.Clear
  214. on error resume next
  215. Dim objService 'holds connection object
  216. Dim objNICAdapterCollection 'holds adapter collection
  217. Dim objNICAdapter 'holds each instance of the collection
  218. Dim intRetVal 'holds return value
  219. Dim objNicName 'holds nicname object
  220. Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  221. Set objNICAdapterCollection = objService.ExecQuery("SELECT * from Win32_NetworkAdapter where DeviceID="+CStr(strAdapterID))
  222. For each objNICAdapter in objNICAdapterCollection
  223. Set objNicName = Server.CreateObject("Microsoft.NAS.NicName")
  224. intRetVal = objNicName.Set(objNICAdapter.PNPDeviceID,strConnName)
  225. if Err.number <> 0 then
  226. SA_SetErrMsg L_UNABLETOSETCONNNAME_ERRORMESSAGE & "(" & Hex(Err.Number) & ")"
  227. SetConnectionName = false
  228. exit function
  229. end if
  230. Next
  231. SetConnectionName = true
  232. 'Release the objects
  233. Set objNicName = nothing
  234. Set objNICAdapterCollection = nothing
  235. set objService = nothing
  236. End Function
  237. %>