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.

485 lines
16 KiB

  1. <%@Language=VbScript%>
  2. <% Option Explicit %>
  3. <% '------------------------------------------------------------------------------------
  4. ' nicappletalk_prop.asp: Displays and updates the appletalk settings for specific NIC
  5. '
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '
  8. ' Date Description
  9. '08-Mar-01 Creation date
  10. '05-Apr-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. ' Form Variables
  19. '-------------------------------------------------------------------------
  20. Dim F_strDesiredZone ' Stores the desired zone for the adapter
  21. Dim G_bIsDefaultAppleTalkPort ' NIC is the default AppleTalk port, can NOT disable AppleTalk on this NIC
  22. Dim G_bAppleTalkEnabled ' AppleTalk enable checkbox value
  23. Dim F_strClassID ' holds GUID
  24. '-------------------------------------------------------------------------
  25. ' Global Variables
  26. '-------------------------------------------------------------------------
  27. Dim page 'variable that receives the output page object when
  28. 'creating a page
  29. Dim rc 'return value for CreatePage
  30. Dim G_strConnName 'holds the Connection name
  31. Dim G_strDeviceID 'holds the device id value
  32. Dim G_strPortChecked 'holds the checked status of default port
  33. Dim G_arrZones 'holds appletalk zones list
  34. Dim CONST_ERROR_ADAPTER_NOTCONFIG
  35. CONST_ERROR_ADAPTER_NOTCONFIG = &H5
  36. Const CONST_PORT_STATE_ON = "on"
  37. 'Create property page
  38. Call SA_CreatePage(L_APPLETALKPAGETITLE_TEXT,"",PT_PROPERTY,page)
  39. 'Serve the page
  40. Call SA_ShowPage(Page)
  41. '-------------------------------------------------------------------------
  42. 'Function: OnInitPage()
  43. 'Description: Called to signal first time processing for this page.
  44. ' Use this method to do first time initialization tasks
  45. 'Input Variables: PageIn,EventArg
  46. 'Output Variables: PageIn,EventArg
  47. 'Returns: True/False
  48. 'Global Variables: None
  49. '-------------------------------------------------------------------------
  50. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  51. Call SA_TraceOut(SA_GetScriptFileName(), "OnInitPage" )
  52. Call OTS_GetTableSelection(SA_DEFAULT, 1, G_strDeviceID )
  53. 'Gets the connection name
  54. G_strConnName = GetConnectionName()
  55. 'Gets the appletalk zones
  56. Call getZonesList()
  57. if( TRUE = G_bIsDefaultAppleTalkPort ) then
  58. Call SA_TraceOut(SA_GetScriptFileName(), "Current NIC is default AppleTalk port, can not disable AppleTalk.")
  59. G_strPortChecked = "checked"
  60. else
  61. Call SA_TraceOut(SA_GetScriptFileName(), "Current NIC is NOT default AppleTalk port, can enable/disable AppleTalk.")
  62. G_strPortChecked = ""
  63. end if
  64. OnInitPage = True
  65. End Function
  66. '-------------------------------------------------------------------------
  67. 'Function: OnServePropertyPage()
  68. 'Description: Called when the page needs to be served.Use this
  69. ' method to serve content
  70. 'Input Variables: PageIn,EventArg
  71. 'Output Variables: PageIn,EventArg
  72. 'Returns: True/False
  73. 'Global Variables: L_*, G_*, F_*
  74. '-------------------------------------------------------------------------
  75. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  76. Call SA_TraceOut(SA_GetScriptFileName(), "OnServePropertyPage" )
  77. 'serve common javascript required for the page
  78. Call ServeCommonJavaScript()
  79. %>
  80. <TABLE BORDER=0 CELLSPACING=0 CELLPADDING=2 >
  81. <TR>
  82. <td class="Tasksbody" nowrap COLSPAN=4><B><%=G_strConnName%></B></td>
  83. </TR>
  84. <TR>
  85. <td COLSPAN=4>&nbsp;</td>
  86. </TR>
  87. <TR>
  88. <TD class="Tasksbody" >
  89. <% if ( TRUE = G_bIsDefaultAppleTalkPort ) Then %>
  90. <input NAME="chkIsDefaultAppleTalkPort" id="chkIsDefaultAppleTalkPort" TYPE="Checkbox" checked disabled TABINDEX=1 >
  91. <input NAME="chkEnableAppleTalk" TYPE="hidden" value="<%=CONST_PORT_STATE_ON%>" >
  92. <% else %>
  93. <input NAME="chkEnableAppleTalk" TYPE="Checkbox" value="<%=CONST_PORT_STATE_ON%>" <%=G_strPortChecked %> TABINDEX=1 OnClick="EnableAppleTalkZoneList();">
  94. <% end if %>
  95. </TD>
  96. <TD class="Tasksbody" >
  97. <%=L_ENABLEAPPLETALKCON_TEXT%>
  98. </TD>
  99. </TR>
  100. <TR>
  101. <TD>
  102. &nbsp;
  103. </TD>
  104. <TD class="Tasksbody" >
  105. <%=L_ZONE_TEXT%>
  106. </TD>
  107. </TR>
  108. <TR>
  109. <TD>
  110. &nbsp;
  111. </TD>
  112. <TD class="Tasksbody" >&nbsp;&nbsp;&nbsp;
  113. <SELECT name="lstZone" TABINDEX=2 style=" WIDTH: 155px">
  114. <%
  115. 'emit appletalk zones to the list box
  116. Call ServeZonesList()
  117. %>
  118. </SELECT>
  119. </TD>
  120. </TR>
  121. <TR>
  122. <TD>
  123. &nbsp;
  124. </TD>
  125. </TR>
  126. <TR>
  127. <TD>
  128. </TD>
  129. <TD class="Tasksbody" >
  130. <%=L_DESC_TEXT%>
  131. </TD>
  132. </TR>
  133. </TABLE>
  134. <input type="hidden" name="hdnClassID" value="<%=F_strClassID%>" >
  135. <%
  136. OnServePropertyPage = True
  137. End Function
  138. '-------------------------------------------------------------------------
  139. 'Function: OnPostBackPage()
  140. 'Description: Called to signal that the page has been posted-back.
  141. 'Input Variables: PageIn,EventArg
  142. 'Output Variables: PageIn,EventArg
  143. 'Returns: True/False
  144. 'Global Variables: None
  145. '-------------------------------------------------------------------------
  146. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  147. Dim sCheckValue
  148. Call SA_TraceOut(SA_GetScriptFileName(), "OnPostBackPage" )
  149. F_strDesiredZone =Request.Form("lstZone")
  150. '
  151. ' Is Enable AppleTalk Checked? When checked the value is returned, otherwise
  152. ' empty value is returned. Therefore, we just check for a non-empty value.
  153. '
  154. sCheckValue = Request.Form("chkEnableAppleTalk")
  155. If ( Len(sCheckValue) > 0 ) Then
  156. G_bAppleTalkEnabled = TRUE
  157. G_strPortChecked = "checked" ' Remember the checked state
  158. else
  159. G_bAppleTalkEnabled = FALSE
  160. G_strPortChecked = "" ' Remember the checked state
  161. End If
  162. Call SA_TraceOut(SA_GetScriptFileName(), "Enable AppleTalk = " + CStr(G_bAppleTalkEnabled))
  163. F_strClassID =Request.Form("hdnClassID")
  164. OnPostBackPage = True
  165. End Function
  166. '-------------------------------------------------------------------------
  167. 'Function: OnSubmitPage()
  168. 'Description: Called when the page has been submitted for processing.
  169. ' Use this method to process the submit request.
  170. 'Input Variables: PageIn,EventArg
  171. 'Output Variables: PageIn,EventArg
  172. 'Returns: True/False
  173. 'Global Variables: None
  174. '-------------------------------------------------------------------------
  175. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  176. Call SA_TraceOut(SA_GetScriptFileName(), "OnSubmitPage" )
  177. 'Set the appletalk settings
  178. OnSubmitPage = SetAppleTalkSettings()
  179. End Function
  180. '-------------------------------------------------------------------------
  181. 'Function: OnClosePage()
  182. 'Description: Called when the page is about closed.Use this method
  183. ' to perform clean-up processing
  184. 'Input Variables: PageIn,EventArg
  185. 'Output Variables: PageIn,EventArg
  186. 'Returns: True/False
  187. 'Global Variables: None
  188. '-------------------------------------------------------------------------
  189. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  190. Call SA_TraceOut(SA_GetScriptFileName(), "OnClosePage" )
  191. OnClosePage = TRUE
  192. End Function
  193. '-------------------------------------------------------------------------
  194. 'Function: ServeCommonJavaScript
  195. 'Description: Serves in initialiging the values,setting the form
  196. ' data and validating the form values
  197. 'Input Variables: None
  198. 'Output Variables: None
  199. 'Returns: True/False
  200. 'Global Variables: None
  201. '-------------------------------------------------------------------------
  202. Function ServeCommonJavaScript()
  203. Err.Clear
  204. On Error Resume Next
  205. Call SA_TraceOut(SA_GetScriptFileName(), "ServeCommonJavaScript" )
  206. %>
  207. <script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  208. </script>
  209. <script language="JavaScript">
  210. function Init()
  211. {
  212. //Enable or disable the Appletalk zone list box
  213. EnableAppleTalkZoneList();
  214. return true;
  215. }
  216. function ValidatePage()
  217. {
  218. return true;
  219. }
  220. function SetData()
  221. {
  222. return true;
  223. }
  224. // This function is used to enable or disable zone list box
  225. function EnableAppleTalkZoneList()
  226. {
  227. //
  228. // If this NIC is the default AppleTalk port then
  229. // enable the zone selection list
  230. if ( document.getElementById("chkIsDefaultAppleTalkPort") != null )
  231. {
  232. document.frmTask.lstZone.disabled=false;
  233. return;
  234. }
  235. //
  236. // Otherwise, zone selection list is only enabled if the
  237. // enable AppleTalk checkbox is checked.
  238. if(document.frmTask.chkEnableAppleTalk.checked == true)
  239. {
  240. document.frmTask.lstZone.disabled=false;
  241. }
  242. else
  243. {
  244. document.frmTask.lstZone.disabled=true;
  245. }
  246. }
  247. </script>
  248. <%
  249. End Function
  250. '-------------------------------------------------------------------------
  251. 'Function: SetAppleTalkSettings
  252. 'Description: sets the AppleTalk settings
  253. 'Input Variables: None
  254. 'Output Variables: None
  255. 'Returns: Boolean
  256. 'Global Variables: F_strDesiredZone holds selected zone
  257. ' F_strClassID hold GUID of adapter
  258. '-------------------------------------------------------------------------
  259. Function SetAppleTalkSettings()
  260. Call SA_TraceOut(SA_GetScriptFileName(), "Entering SetAppleTalkSettings" )
  261. SetAppleTalkSettings = true
  262. if( G_bAppleTalkEnabled ) then
  263. Call SA_TraceOut(SA_GetScriptFileName(), "AppleTalk is enabled")
  264. Call SA_TraceOut(SA_GetScriptFileName(), "NewZone:" + F_strDesiredZone)
  265. Dim oAppleTalk 'holds Appletalk object
  266. Set oAppleTalk = CreateObject("MSSAAppleTalk.AppleTalk")
  267. if Err.number <> 0 then
  268. SA_SetErrMsg L_UNABLETOGETINSTANCE_APPLETALK_ERRORMESSAGE
  269. Call SA_TraceOut(SA_GetScriptFileName(), "CreateObject(MSSAAppleTalk.AppleTalk) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  270. SetAppleTalkSettings = false
  271. exit function
  272. end if
  273. if ( F_strDesiredZone <> "") then
  274. oAppleTalk.Zone(F_strClassID) = F_strDesiredZone
  275. if Err.number <> 0 then
  276. SA_SetErrMsg L_UNABLETOSETZONE_ERRORMESSAGE
  277. Call SA_TraceOut(SA_GetScriptFileName(), "oAppleTalk.Zone("+CStr(F_strClassID)+") = "+CStr(F_strDesiredZone) + " failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  278. SetAppleTalkSettings = false
  279. exit function
  280. end if
  281. end if
  282. oAppleTalk.SetAsDefaultPort(F_strClassID) 'set defaultport for appletalk
  283. if Err.number <> 0 then
  284. SA_SetErrMsg L_UNABLETOSETDEFPORT_ERRORMESSAGE
  285. Call SA_TraceOut(SA_GetScriptFileName(), "oAppleTalk.SetAsDefaultPort("+CStr(F_strClassID)+") failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  286. SetAppleTalkSettings = false
  287. exit function
  288. end if
  289. 'Release the object
  290. set oAppleTalk = Nothing
  291. else
  292. Call SA_TraceOut(SA_GetScriptFileName(), "AppleTalk is DISABLED")
  293. end if
  294. End Function
  295. '-------------------------------------------------------------------------
  296. 'Function: GetConnectionName
  297. 'Description: gets the connection name
  298. 'Input Variables: None
  299. 'Output Variables: None
  300. 'Returns: None
  301. 'Global Variables: G_strDeviceID
  302. 'Function used : GetNicName
  303. '-------------------------------------------------------------------------
  304. Function GetConnectionName()
  305. Call SA_TraceOut(SA_GetScriptFileName(), "GetConnectionName" )
  306. 'get Adapter Name
  307. GetConnectionName = GetNicName( G_strDeviceID )
  308. End Function
  309. '-------------------------------------------------------------------------
  310. 'Sub routine: ServeZonesList
  311. 'Description: gets the Zones list
  312. 'Input Variables: None
  313. 'Output Variables: None
  314. 'Returns: None
  315. 'Global Variables : F_strDesiredZone 'holds selected zone
  316. ' G_arrZones 'holds array of zones
  317. '-------------------------------------------------------------------------
  318. Sub ServeZonesList()
  319. Dim sZone 'holds appletalk zone
  320. Dim count 'holds zone count
  321. Call SA_TraceOut(SA_GetScriptFileName(), "ServeZonesList" )
  322. '
  323. ' Display the list of zones
  324. If ( IsArray(G_arrZones) ) Then
  325. For count = 0 to CInt(UBound(G_arrZones))
  326. sZone = CStr(G_arrZones(count))
  327. if(sZone = F_strDesiredZone) then
  328. Response.Write "<OPTION VALUE=" & chr(34) & sZone _
  329. & chr(34)& " SELECTED>" & sZone & " </OPTION>"
  330. else
  331. Response.Write "<OPTION VALUE=" & chr(34) & sZone _
  332. & chr(34)& " >" & sZone & " </OPTION>"
  333. end if
  334. Next
  335. End If
  336. End Sub
  337. '-------------------------------------------------------------------------
  338. 'Function: getZonesList
  339. 'Description: gets the appletalk zones list
  340. 'Input Variables: None
  341. 'Output Variables: None
  342. 'Returns: None
  343. 'Global Variables/Constants :CONST_WMI_WIN32_NAMESPACE
  344. ' G_strDeviceID holds GUID of adapter
  345. ' F_strClassID holds GUID of adapter
  346. '-------------------------------------------------------------------------
  347. Function getZonesList()
  348. Err.Clear
  349. On Error Resume Next
  350. Dim objService 'to hold WMI Connection object
  351. Dim objCollection 'to hold IP Adapter Collection
  352. Dim objAdapterInst 'to hold Adapter instance
  353. Dim oAppleTalk 'to hold Appletalk object
  354. Dim strDefPort 'to hold default port
  355. Const CONST_ZONELIST = "ZoneList"
  356. Call SA_TraceOut(SA_GetScriptFileName(), "Select * from Win32_NetworkAdapterConfiguration where index=" + CStr(G_strDeviceID) )
  357. 'Get WMI Connection
  358. Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  359. Set objCollection = objService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration where index=" + CStr(G_strDeviceID))
  360. if Err.number <> 0 then
  361. Call SA_TraceOut(SA_GetScriptFileName(), "objService.ExecQuery() failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  362. SA_ServeFailurePage L_UNABLETOGETADAPTERINSTANCE_ERRORMESSAGE
  363. exit function ' if appletalk protocol is not installed
  364. end if
  365. for each objAdapterInst in objCollection
  366. F_strClassID = objAdapterInst.SettingID
  367. exit for
  368. Next
  369. 'get the instance of Appletalk COM object
  370. Set oAppleTalk = CreateObject("MSSAAppleTalk.AppleTalk")
  371. if Err.number <> 0 then
  372. Call SA_TraceOut(SA_GetScriptFileName(), "CreateObject(MSSAAppleTalk.AppleTalk) failed: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  373. SA_ServeFailurePage L_UNABLETOGETINSTANCE_APPLETALK_ERRORMESSAGE
  374. exit function
  375. end if
  376. 'get Appletalk zones
  377. G_arrZones = oAppleTalk.GetZones(F_strClassID)
  378. 'get desired zone
  379. F_strDesiredZone = oAppleTalk.Zone(F_strClassID)
  380. 'get default port
  381. strDefPort = oAppleTalk.IsDefaultPort(F_strClassID)
  382. if Err.number <> 0 then
  383. Call SA_TraceOut(SA_GetScriptFileName(), "Unexpected error getting AppleTalk settings, error: " + CStr(Hex(Err.Number)) + " " + Err.Description)
  384. SA_ServeFailurePage L_APPLETALK_NOTCONFIG_ERRORMESSAGE
  385. exit function
  386. end if
  387. if ( Cstr(strDefPort) = "1") then
  388. G_bIsDefaultAppleTalkPort = TRUE
  389. else
  390. G_bIsDefaultAppleTalkPort = FALSE
  391. end if
  392. 'Release objects
  393. Set oAppleTalk = Nothing
  394. Set objService = Nothing
  395. Set objCollection = Nothing
  396. End Function
  397. %>