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.

768 lines
26 KiB

  1. <% @Language=VbScript%>
  2. <% Option Explicit %>
  3. <%
  4. '----------------------------------------------------------------------------
  5. ' nicwins_prop.asp: display and update the WINS properties of NIC.
  6. ' Description: this page displays the wins server properties of NIC and
  7. ' allows to change the properties
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 16-Jan-01 Creation date
  12. ' 09-Mar-01 Modified date
  13. '-----------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp"-->
  16. <!-- #include file="loc_nicspecific.asp" -->
  17. <!-- #include file="inc_network.asp" -->
  18. <%
  19. '-------------------------------------------------------------------------
  20. ' Global Variables
  21. '-------------------------------------------------------------------------
  22. Dim G_objService 'Object to SWBEM service
  23. Dim page 'Variable that receives the output page object when
  24. 'creating a page
  25. Dim rc 'Return value for CreatePage
  26. Dim SOURCE_FILE 'To hold source file name
  27. SOURCE_FILE = SA_GetScriptFileName()
  28. '-------------------------------------------------------------------------
  29. ' Global Form Variables
  30. '-------------------------------------------------------------------------
  31. Dim F_strNWadapter 'NIC adapter description
  32. Dim F_nNWadapterindex 'NIC adapter index
  33. Dim F_strWinservers 'Contains #-seperated list of WINS servers
  34. Dim F_radSelected 'Which option is selected
  35. ' "1" means DHCP enabled
  36. ' "2" means Manual Settings
  37. 'Create property page
  38. rc=SA_CreatePage(L_WINSTASKTITLE_TEXT,"",PT_PROPERTY,page)
  39. 'Serve the page
  40. If(rc=0) then
  41. SA_ShowPage(Page)
  42. End if
  43. '-------------------------------------------------------------------------
  44. 'Function: OnInitPage()
  45. 'Description: Called to signal first time processing for this page.
  46. ' Use this method to do first time initialization tasks
  47. 'Input Variables: PageIn,EventArg
  48. 'Output Variables: PageIn,EventArg
  49. 'Returns: True/False
  50. 'Global Variables: None
  51. '-------------------------------------------------------------------------
  52. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  53. Call SA_TraceOut(SOURCE_FILE,"OnInitPage")
  54. 'gets the default values of the wins server
  55. OnInitPage = GetDefaultValues()
  56. End Function
  57. '-------------------------------------------------------------------------
  58. 'Function: OnServePropertyPage()
  59. 'Description: Called when the page needs to be served.Use this
  60. ' method to serve content
  61. 'Input Variables: PageIn,EventArg
  62. 'Output Variables: PageIn,EventArg
  63. 'Returns: True/False
  64. 'Global Variables: None
  65. '-------------------------------------------------------------------------
  66. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  67. Call SA_TraceOut( SOURCE_FILE, "OnServePropertyPage")
  68. Call ServeCommonJavaScript()
  69. 'serves the html content
  70. Call ServePage()
  71. OnServePropertyPage = True
  72. End Function
  73. '-------------------------------------------------------------------------
  74. 'Function: OnPostBackPage()
  75. 'Description: Called to signal that the page has been posted-back.
  76. 'Input Variables: PageIn,EventArg
  77. 'Output Variables: PageIn,EventArg
  78. 'Returns: True/False
  79. 'Global Variables: None
  80. '-------------------------------------------------------------------------
  81. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  82. Call SA_TraceOut( SOURCE_FILE, "OnPostBackPage")
  83. 'To get the value of NIC adapter index value after form is submitted
  84. F_nNWadapterindex = Request.Form("hdnNWAdapterID")
  85. 'List of winsservers after form has been submitted
  86. F_strWinservers =Request.Form("hdnServerslist")
  87. ' The radio button to be selected - contains 1 or 2 only
  88. F_radSelected = Request.Form("hdnRadioSelected")
  89. OnPostBackPage = True
  90. End Function
  91. '-------------------------------------------------------------------------
  92. 'Function: OnSubmitPage()
  93. 'Description: Called when the page has been submitted for processing.
  94. ' Use this method to process the submit request.
  95. 'Input Variables: PageIn,EventArg
  96. 'Output Variables: PageIn,EventArg
  97. 'Returns: True/False
  98. 'Global Variables: In:G_objService-Getting WMI connection Object
  99. ' Out:F_nNWadapterindex-Getting NIC adapter Index
  100. ' Out:F_radSelected-Getting radio button selection
  101. ' Out:F_strWinservers-Getting new list wins servers
  102. ' L_(*)-Localization content
  103. '-------------------------------------------------------------------------
  104. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  105. Call SA_TraceOut( SOURCE_FILE, "OnSubmitPage")
  106. 'Getting WMI connection Object on error displays failure page
  107. Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  108. call GetWINSConfiguration(1)
  109. 'Updating the wins server settings
  110. If SetWINSserverConfiguration() Then
  111. OnSubmitPage = True
  112. Else
  113. OnSubmitPage = False
  114. End if
  115. 'Release the object
  116. set G_objService = nothing
  117. End Function
  118. '-------------------------------------------------------------------------
  119. 'Function: OnClosePage()
  120. 'Description: Called when the page is about closed.Use this method
  121. ' to perform clean-up processing
  122. 'Input Variables: PageIn,EventArg
  123. 'Output Variables: PageIn,EventArg
  124. 'Returns: True/False
  125. 'Global Variables: None
  126. '-------------------------------------------------------------------------
  127. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  128. Call SA_TraceOut( SOURCE_FILE, "OnClosePage")
  129. OnClosePage = TRUE
  130. End Function
  131. '-------------------------------------------------------------------------
  132. 'Function: ServeCommonJavaScript
  133. 'Description: Serves in initializing the values,setting the form
  134. ' data and validating the form values
  135. 'Input Variables: None
  136. 'Output Variables: None
  137. 'Returns: None
  138. 'Global Variables: None
  139. '-------------------------------------------------------------------------
  140. Function ServeCommonJavaScript()
  141. %>
  142. <Script language="JavaScript" src ="<%=m_VirtualRoot%>inc_global.js">
  143. </Script>
  144. <Script language="JavaScript">
  145. // Set the Intial Form load values
  146. function Init()
  147. {
  148. //If "Obtain configuration from DHCP server " checkbox
  149. // is checked then disbable configure manually controls
  150. if(document.frmTask.radIP[0].checked)
  151. {
  152. HandleControls(true)
  153. }
  154. var intLength = document.frmTask.lstSelectwins.length;
  155. switch(intLength)
  156. {
  157. case 0: // If server list is empty, disable the Remove button
  158. document.frmTask.btnRemovewinsserver.disabled = true;
  159. document.frmTask.txtWinsserver.focus();
  160. break;
  161. case 2: // If server list contains two items, disable the Add button
  162. // select the first option in listbox
  163. document.frmTask.btnAddwinsserver.disabled = true;
  164. document.frmTask.txtWinsserver.disabled = true;
  165. document.frmTask.lstSelectwins.options[0].selected = true;
  166. document.frmTask.btnRemovewinsserver.disabled = false;
  167. break;
  168. default:// If server list contains one item, enable the Add button
  169. // select the first option in listbox
  170. document.frmTask.btnAddwinsserver.disabled = false;
  171. document.frmTask.btnRemovewinsserver.disabled = false;
  172. document.frmTask.lstSelectwins.options[0].selected = true;
  173. break;
  174. }
  175. //Disables Add button until a valid key is pressed.
  176. disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  177. // disablingthe controls lisbox, textbox, Add &
  178. // remove buttons if "obtain configuration from dhcp server"
  179. // is checked
  180. if(document.frmTask.radIP[0].checked)
  181. {
  182. HandleControls(true)
  183. }
  184. }
  185. // ValidatePage Function
  186. // ------------------
  187. // This function is called by the Web Framework as part of the
  188. // submit processing. Use this function to validate user input. Returning
  189. // false will cause the submit to abort.
  190. //
  191. // This function must be included or a javascript runtime error will occur.
  192. //
  193. // Returns: True if the page is OK, false if error(s) exist.
  194. function ValidatePage()
  195. {
  196. return true;
  197. }
  198. // SetData Function
  199. // --------------
  200. // This function is called by the Web Framework and is called
  201. // only if ValidatePage returned a success (true) code. Typically you would
  202. // modify hidden form fields at this point.
  203. //
  204. // This function must be included or a javascript runtime error will occur.
  205. //
  206. function SetData()
  207. {
  208. if(document.frmTask.radIP[0].checked)
  209. document.frmTask.hdnRadioSelected.value = "1"
  210. else
  211. document.frmTask.hdnRadioSelected.value = "2"
  212. }
  213. //This function is called on click of ADD button validates the
  214. // IP address and moves to the WINS servers listbox.
  215. function verifyIPaddress()
  216. {
  217. var intErrvalue;
  218. ClearErr();
  219. intErrvalue =isValidIP(document.frmTask.txtWinsserver);
  220. if (intErrvalue == 0)
  221. {
  222. moveIPtoWINSServerListbox(document.frmTask.txtWinsserver.value);
  223. document.frmTask.btnRemovewinsserver.disabled = false;
  224. }
  225. else
  226. {
  227. SA_DisplayErr ( '<%=SA_EscapeQuotes(L_IP_ERRORMESSAGE)%>');
  228. }
  229. }
  230. //Function moves IP to WINSserver Listbox.
  231. //Disables ADD button after adding 2 IP address.
  232. function moveIPtoWINSServerListbox(IPaddress)
  233. {
  234. var objWINSListbox = document.frmTask.lstSelectwins;
  235. var objRemoveButton =document.frmTask.btnRemovewinsserver;
  236. var strWINSList = document.frmTask.hdnServerslist.value;
  237. //Function adds IP to WINS listbox and selects last IP.
  238. //Displays Error on Duplicate IP address.
  239. if((addToListBox(objWINSListbox,objRemoveButton,IPaddress,IPaddress))==false)
  240. {
  241. SA_DisplayErr('<%=SA_EscapeQuotes(L_IPALREADYEXISTS_ERRORMESSAGE)%>');
  242. }
  243. else
  244. {
  245. document.frmTask.txtWinsserver.value = "";
  246. }
  247. //Add new IP to hidden text list of IP addresses
  248. strWINSList = strWINSList + IPaddress + "#";
  249. document.frmTask.hdnServerslist.value = strWINSList;
  250. //Disable the Add button if two or more WINS servers are listed
  251. if(objWINSListbox.length > 1) {
  252. document.frmTask.btnAddwinsserver.disabled = true;
  253. document.frmTask.txtWinsserver.disabled = true;
  254. }
  255. else
  256. {
  257. document.frmTask.txtWinsserver.disabled = false;
  258. disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  259. document.frmTask.txtWinsserver.focus();
  260. }
  261. }
  262. //Removes the selected IP from the WINSServerlistbox.
  263. //Disables Remove button if Listbox is empty.
  264. function removeIPFromWINSserverListbox()
  265. {
  266. var strRemovePattern;
  267. var objWINSListbox = document.frmTask.lstSelectwins ;
  268. var strWINSList = document.frmTask.hdnServerslist.value;
  269. var intSelectedIndex;
  270. ClearErr();
  271. if (objWINSListbox.value != "")
  272. {
  273. intSelectedIndex = objWINSListbox.selectedIndex ;
  274. //Removing the selected IP address from WINSstring
  275. strRemovePattern = objWINSListbox.value + "#";
  276. strWINSList =strWINSList.replace(strRemovePattern,"");
  277. document.frmTask.hdnServerslist.value = strWINSList;
  278. objWINSListbox.options[objWINSListbox.selectedIndex]= null;
  279. //Set focus on next list element,if list empty Disable the remove button
  280. if(objWINSListbox.length == 0)
  281. {
  282. document.frmTask.btnRemovewinsserver.disabled = true ;
  283. document.frmTask.txtWinsserver.focus();
  284. }
  285. else
  286. {
  287. if(objWINSListbox.length < 2)
  288. {
  289. disableAddButton(document.frmTask.txtWinsserver,document.frmTask.btnAddwinsserver);
  290. document.frmTask.txtWinsserver.disabled = false;
  291. document.frmTask.txtWinsserver.focus();
  292. }
  293. if(intSelectedIndex < objWINSListbox.length)
  294. objWINSListbox.options[intSelectedIndex].selected = true;
  295. else
  296. objWINSListbox.options[objWINSListbox.length-1].selected = true;
  297. }
  298. }
  299. }
  300. // Depending on the flag the controls lisbox, textbox, Add &
  301. // remove buttons are disabled or enabled
  302. function HandleControls(strFlag)
  303. {
  304. if ( strFlag )
  305. {
  306. document.frmTask.btnRemovewinsserver.disabled = true;
  307. document.frmTask.btnAddwinsserver.disabled = true;
  308. document.frmTask.txtWinsserver.disabled = true;
  309. if(document.frmTask.lstSelectwins.length > 0)
  310. {
  311. document.frmTask.lstSelectwins.selectedIndex = -1;
  312. }
  313. document.frmTask.lstSelectwins.disabled = true;
  314. }
  315. else
  316. {
  317. document.frmTask.btnRemovewinsserver.disabled = false;
  318. document.frmTask.btnAddwinsserver.disabled = false;
  319. }
  320. }
  321. //Handling Enabling of Wins controls and selects first item in the listbox and
  322. //sets the focus to Remove button
  323. function enableWINSControls()
  324. {
  325. document.frmTask.txtWinsserver.disabled = false;
  326. document.frmTask.txtWinsserver.value=""
  327. document.frmTask.txtWinsserver.focus()
  328. document.frmTask.lstSelectwins.disabled = false;
  329. // if any wins entries present, select the first
  330. // and enable the Remove button
  331. if(document.frmTask.lstSelectwins.length > 0)
  332. {
  333. document.frmTask.lstSelectwins.selectedIndex = 0;
  334. document.frmTask.btnRemovewinsserver.disabled = false;
  335. }
  336. }
  337. //Handling Ok button when press 'Enter' after entering a value in 'Wins server address:' Text box
  338. function HandleOk(objWins)
  339. {
  340. if(window.event.keyCode!=27)
  341. {
  342. checkKeyforIPAddress(objWins);
  343. }
  344. if(window.event.keyCode==0)
  345. {
  346. verifyIPaddress()
  347. }
  348. }
  349. </script>
  350. <%
  351. End Function
  352. '-------------------------------------------------------------------------
  353. ' Subroutine name: ServePage
  354. ' Description: Serves few Javascript functions and helps in
  355. ' displaying HTML of the page
  356. ' Input Variables: None.
  357. ' Output Variables: None
  358. ' Return Values: None.
  359. ' Global Variables: In:G_objService-Getting WMI connection Object
  360. ' Out:F_nNWadapterindex-Getting NIC adapter Index
  361. ' Out:F_radSelected-Getting radio button selection
  362. ' Out:F_strWinservers-Getting new list wins servers
  363. ' L_(*)-Localization content
  364. '-------------------------------------------------------------------------
  365. Sub ServePage()
  366. Err.CLear
  367. On Error Resume Next
  368. Dim objNetAdapter 'To hold network adapter object instance
  369. Dim strDHCPEnabled 'to hold the value Dhcp enabled or not
  370. Call SA_TraceOut( SOURCE_FILE, "ServePage()")
  371. ' Getting the Network adapter objects
  372. set objNetAdapter = getNetworkAdapterObject(G_objService,F_nNWadapterindex)
  373. If Err.number <>0 then
  374. Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter Object-ServePage()")
  375. Call SA_ServeFailurePage(L_NIC_ADAPTERINSTANCEFAILED_ERRORMESSAGE)
  376. Exit Sub
  377. End If
  378. 'Get Whether the DHCP is enabled on the NIC.
  379. strDHCPEnabled = isDHCPenabled(objNetAdapter)
  380. %>
  381. <!--html content to be displayed-->
  382. <table border="0" cellspacing="0" cellpadding="2">
  383. <tr>
  384. <td class='TasksBody' nowrap colspan="4"><B><%=GetNicName(F_nNWadapterindex)%></B></td>
  385. </tr>
  386. <tr>
  387. <td class='TasksBody' colspan="4">&nbsp;</td>
  388. </tr>
  389. <tr>
  390. <td class='TasksBody' nowrap >
  391. <%=L_CONFIGURATION_TEXT%>
  392. </td>
  393. <td class='TasksBody' colspan="3">
  394. <input type="radio" class="FormRadioButton" name="radIP" value="IPDEFAULT"
  395. <% 'if DHCP is disabled then disable
  396. 'this radio button
  397. If Not strDHCPEnabled Then
  398. response.write " Disabled"
  399. Else
  400. response.write " Checked Disabled"
  401. End If
  402. %>
  403. onClick="EnableOK();HandleControls(true)">
  404. <%=L_OBTAINIPFROMDHCP_TEXT%>
  405. </td>
  406. </tr>
  407. <tr>
  408. <td class='TasksBody'>&nbsp;</TD>
  409. <td class='TasksBody' nowrap colspan="3">
  410. <input type="radio" class="FormRadioButton" name="radIP" value="IPMANUAL"
  411. <%
  412. 'if DHCP is disabled then disable this radio button
  413. If Not strDHCPEnabled Then
  414. response.write " Checked Disabled"
  415. else
  416. response.write " Disabled "
  417. End If
  418. %>
  419. onClick="EnableOK(); enableWINSControls();" >
  420. <%=L_NIC_IP_CONFIGUREMANUALLY%>
  421. </td>
  422. </tr>
  423. <tr>
  424. <td class='TasksBody' nowrap colspan="4" align="right">
  425. <%=L_WINS_SERVER_ADDRESS_TEXT%>
  426. </td>
  427. </tr>
  428. <tr>
  429. <td class='TasksBody' nowrap valign=top >
  430. <%=L_WINSADDRESSES_TEXT%>
  431. </td>
  432. <td class='TasksBody' valign="top" >
  433. <select name="lstSelectwins" style="width:200px" size="6" tabindex="1" class="FormField"> <% OutputWINSServersToListbox() %></select>
  434. </td>
  435. <td class='TasksBody' nowrap align=center valign=TOP >
  436. <%
  437. Call SA_ServeOnClickButtonEx(L_BUTTON_ADD_TEXT, "", "JavaScript:verifyIPaddress()", 60, 0, "DISABLED", "btnAddwinsserver")
  438. %>
  439. <br><br><br><br><br>
  440. <%
  441. Call SA_ServeOnClickButtonEx(L_BUTTON_REMOVE_TEXT, "", "javaScript:removeIPFromWINSserverListbox()", 60, 0, "DISABLED", "btnRemovewinsserver")
  442. %>
  443. </td>
  444. <td class='TasksBody' valign=top >
  445. <input class='FormField' type=text name="txtWinsserver" size=15 style="WIDTH:135px" maxlength="15" tabindex="3" onKeyUP="disableAddButton(txtWinsserver,btnAddwinsserver)" onKeypress="HandleOk(this)" >
  446. </TD>
  447. </TR>
  448. </TABLE>
  449. <input name="hdnServerslist" type="Hidden" value="<%=F_strWinservers%>" >
  450. <input name="hdnNWAdapterID" type="Hidden" value="<%=F_nNWadapterindex%>" >
  451. <input name="hdnRadioSelected" type="hidden" value="<%=F_radSelected%>">
  452. <%
  453. 'destroying dynamically created objects
  454. Set objNetAdapter=Nothing
  455. End Sub
  456. '-------------------------------------------------------------------------
  457. ' Function Name: GetWINSConfiguration
  458. ' Description: To retrieve the WINS configuration settings
  459. ' for the network adapter from system.
  460. ' Input Variables: nFormReload - a flag value to differentiate
  461. ' intial loading and form submition.
  462. ' Output Variables: None
  463. ' Returns: True/False
  464. ' Global Variables: In : F_nNWadapterindex - Index of adapter(WMI index number)
  465. ' In : L_INVALIDOBJECT_ERRORMESSAGE
  466. ' In : G_objService - WMI Connection Object
  467. ' Out: F_WINSERVER - #-separated list of WINS servers
  468. '
  469. 'On Form intial loading gets the NIC adapter descrition and WINS servers
  470. 'from WMI .Displays the error message on failure of getting object from WMI.
  471. 'On form Reloading/submitting gets only description of NIC adapter.
  472. '-------------------------------------------------------------------------
  473. Function GetWINSConfiguration(nFormReload)
  474. Err.Clear
  475. On Error Resume Next
  476. Const IPCONST="127.0.0.0"
  477. Dim objWinsCfg 'To hold Network adapter object instance
  478. Call SA_TraceOut( SOURCE_FILE, "GetWINSConfiguration()")
  479. Set objWinsCfg = G_objService.Get("Win32_NetworkAdapterConfiguration.Index=" _
  480. & chr(34) & F_nNWadapterindex & chr(34))
  481. 'if initial load failure then ServeFailurePage called else SetErrMsg
  482. If Err.Number <> 0 Then
  483. Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter object-GetWINSConfiguration()")
  484. If nFormReload Then
  485. SA_SetErrMsg L_INVALIDOBJECT_ERRORMESSAGE & " (" & HEX(Err.Number) & ")"
  486. Else
  487. Call SA_ServeFailurePage( L_INVALIDOBJECT_ERRORMESSAGE)
  488. End If
  489. GetWINSConfiguration = FALSE
  490. Exit Function
  491. End If
  492. If (nFormReload) Then
  493. ' Form being reloaded, keep the other values since they
  494. ' are passed through the form.
  495. Exit Function
  496. End If
  497. F_strWinservers = ""
  498. 'WMI returns '127.0.0.0' for server addresses that are not set
  499. 'so we must treat this value same as an unset address
  500. If Len(Trim(objWinsCfg.WINSPrimaryServer)) > 0 Then
  501. If objWinsCfg.WINSPrimaryServer <> IPCONST Then
  502. F_strWinservers = F_strWinservers & objWinsCfg.WINSPrimaryServer & "#"
  503. End If
  504. End If
  505. If Len(Trim(objWinsCfg.WINSSecondaryServer)) > 0 Then
  506. If objWinsCfg.WINSSecondaryServer <> IPCONST Then
  507. F_strWinservers = F_strWinservers & objWinsCfg.WINSSecondaryServer & "#"
  508. End If
  509. End If
  510. GetWINSConfiguration = True
  511. 'Destroying dynamically created objects
  512. Set objWinsCfg=Nothing
  513. End Function
  514. '-------------------------------------------------------------------------
  515. ' Function name: SetWINSserverConfiguration
  516. ' Description: Sets the WINS Configuration for the N/W Adapter.
  517. ' Input Variables: None
  518. ' Output Variables: None
  519. ' Return Values: True on sucess, False on error (and error msg
  520. ' will be set by SetErrMsg)
  521. ' Global Variables: In: F_nNWadapterindex -Index of adapter (WMI index number)
  522. ' In: F_strWinservers - #-separated list of WINS server IPs
  523. ' In: G_objService - WMI Connection Object
  524. ' In: L_SETWINSFAILED_ERRORMESSAGE
  525. ' In: L_INVALIDOBJECT_ERRORMESSAGE
  526. '
  527. ' Updates system with WINS servers as given by F_strWinservers. If an error
  528. ' occurs, sets error message with SetErrMsg and exits with False.
  529. '-------------------------------------------------------------------------
  530. Function SetWINSserverConfiguration()
  531. Err.Clear
  532. On Error Resume Next
  533. Dim objWinsCfg 'To hold Network adapter object instance
  534. Dim strPrimAdd 'To hold Primary Wins server
  535. Dim strSecAdd 'To hold Secondary Wins server
  536. Dim arrWinsSrv 'TO hold the array list of wins servers
  537. Dim nValue 'To hold return value of the Wmi method
  538. Call SA_TraceOut( SOURCE_FILE, "SetWINSserverConfiguration()")
  539. Set objWinsCfg = G_objService.Get("Win32_NetworkAdapterConfiguration.Index=" & _
  540. chr(34) & F_nNWadapterindex & chr(34))
  541. If Err.Number <> 0 Then
  542. Call SA_TraceOut( SOURCE_FILE, "Error in getting Network adapter object-SetWINSserverConfiguration()")
  543. SA_SetErrMsg L_INVALIDOBJECT_ERRORMESSAGE & " (" & HEX(Err.Number) & ")"
  544. SetWINSserverConfiguration = FALSE
  545. Exit Function
  546. End If
  547. arrWinsSrv = split(F_strWinservers, "#")
  548. 'Convert the array into a primary and secondary WINS server,
  549. ' as required by WMI.
  550. strPrimAdd = ""
  551. strSecAdd = ""
  552. If Ubound(arrWinsSrv) > 0 Then
  553. strPrimAdd = arrWinsSrv(0)
  554. If Ubound(arrWinsSrv) > 1 Then
  555. strSecAdd = arrWinsSrv(1)
  556. End If
  557. End If
  558. nValue = objWinsCfg.SetWINSServer(strPrimAdd, strSecAdd)
  559. If (Err.Number <> 0 or nValue <> 0 )Then
  560. Call SA_TraceOut( SOURCE_FILE, "Error in setting wins server settings-SetWINSserverConfiguration()")
  561. SA_SetErrMsg L_SETWINSFAILED_ERRORMESSAGE & " (" & HEX(Err.Number) & ")"
  562. SetWINSserverConfiguration = false
  563. Else
  564. SetWINSserverConfiguration = true
  565. End If
  566. 'Destroying dynamically created objects
  567. Set objWinsCfg=Nothing
  568. End Function
  569. '-------------------------------------------------------------------------
  570. ' Function Name: OutputWINSServersToListbox
  571. ' Description: To display the WINS Servers in the LISTBOX.
  572. ' Input Variables: None.
  573. ' Output Variables: None.
  574. ' Returns: None.
  575. ' Global Variables: In: F_WINSERVER - #-separated list of WINS server IPs
  576. ' This function Outputs WINS servers to the listbox control in the Form.
  577. '-------------------------------------------------------------------------
  578. Function OutputWINSServersToListbox()
  579. Err.Clear
  580. On Error Resume Next
  581. Call SA_TraceOut( SOURCE_FILE, "OutputWINSServersToListbox()")
  582. Dim arrWinsSrv 'To hold the Wins server list
  583. Dim nIndex 'To hold the Wins server list Index
  584. arrWinsSrv = split(F_strWinservers,"#")
  585. nIndex = 0
  586. If (NOT IsNull(arrWinsSrv)) Then
  587. If IsArray(arrWinsSrv) Then
  588. For nIndex = LBound(arrWinsSrv) to UBound(arrWinsSrv)
  589. If arrWinsSrv(nIndex) <> "" Then
  590. Response.Write "<OPTION VALUE=""" & arrWinsSrv(nIndex) & _
  591. """ >" & arrWinsSrv(nIndex) & " </OPTION>"
  592. End If
  593. Next
  594. End If
  595. End If
  596. End Function
  597. '-------------------------------------------------------------------------
  598. 'Function: GetDefaultValues
  599. 'Description: gets default values of wins server setting
  600. 'Input Variables: None
  601. 'Output Variables: None
  602. 'Returns: True/False
  603. 'Global Variables: In:G_objService-Getting WMI connection Object
  604. ' Out:F_nNWadapterindex-Getting NIC adapter Index
  605. ' Out:F_radSelected-Getting radio button selection
  606. ' In:L_(*)-Localization content
  607. '-------------------------------------------------------------------------
  608. Function GetDefaultValues()
  609. Err.Clear
  610. On Error Resume Next
  611. Dim objNetAdapter 'holds network adapter object
  612. Const DHCPON="ON" 'Const for dhcp on
  613. Const DHCPOFF="OFF" 'Const for dhcp off
  614. Call SA_TraceOut( SOURCE_FILE, "GetDefaultValues()")
  615. 'getting NIC adapter Index from area page
  616. F_nNWadapterindex = Request.QueryString("PKey")
  617. 'Getting WMI connection Object on error displays failure page
  618. Set G_objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  619. set objNetAdapter = getNetworkAdapterObject(G_objService,F_nNWadapterindex)
  620. 'getting default wins server settings from system
  621. GetWINSConfiguration(0)
  622. 'checking for the DHCP is enabled or not
  623. If isDHCPenabled(objNetAdapter) Then
  624. F_radSelected = DHCPON
  625. Else
  626. F_radSelected = DHCPOFF
  627. End If
  628. GetDefaultValues=True
  629. 'destroying dynamically created objects
  630. Set objNetAdapter=Nothing
  631. End Function
  632. %>