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.

920 lines
32 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' httpsvc_prop.asp: Allows for the configuration of IP addresses
  6. ' and set the port to listen for HTTP shares web site.
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 22-01-2001 Created date
  12. ' 12-03-2001 Modified Date
  13. '-------------------------------------------------------------------------
  14. %>
  15. <!-- #include virtual="/admin/inc_framework.asp" -->
  16. <!-- #include file="loc_httpsvc.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. ' Global Variables and Constants
  20. '-------------------------------------------------------------------------
  21. Dim G_objHTTPService 'WMI server HTTP shares web site object
  22. Dim G_objService 'WMI server object to get the IP addresses for NIC cards
  23. Dim rc 'framework variable
  24. Dim page 'framework variable
  25. Dim iTabGeneral 'framework variable
  26. Dim SOURCE_FILE 'To hold source file name
  27. SOURCE_FILE = SA_GetScriptFileName()
  28. Const CONST_ARR_STATUS_CHECKED = "CHECKED" 'Constant for radio button checked property
  29. Const CONST_ARR_STATUS_TRUE = "YES" 'Constant for radio button status
  30. Const CONST_ARR_STATUS_FALSE = "NO" 'Constant for radio button status
  31. '-------------------------------------------------------------------------
  32. 'Form Variables
  33. '-------------------------------------------------------------------------
  34. Dim F_strIPAddress 'IP Address to be used
  35. Dim F_nport 'Port Number to be used
  36. Dim F_strradIPAdd 'Value of radio button clicked
  37. Dim F_strAll_IPAddress 'To set the status of the All IP address radio button
  38. Dim F_strJustthis_IPAddress 'To set the status of the Just this IP address radio button
  39. '-------------------------------------------------------------------------
  40. 'END of Form Variables
  41. '-------------------------------------------------------------------------
  42. '
  43. 'Create a Tabbed Property Page
  44. rc = SA_CreatePage( L_PAGETITLE_HTTP_TEXT , "", PT_TABBED, page )
  45. '
  46. 'Add a tab
  47. rc = SA_AddTabPage( page, L_GENERAL_TEXT, iTabGeneral)
  48. '
  49. 'Show the page
  50. rc = SA_ShowPage( page )
  51. '---------------------------------------------------------------------
  52. 'Function: OnInitPage()
  53. 'Description: Called to signal first time processing for this page.
  54. 'Input Variables: PageIn,EventArg
  55. 'Output Variables: PageIn,EventArg
  56. 'Returns: True/False
  57. 'Global Variables: None
  58. '---------------------------------------------------------------------
  59. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  60. 'To get the HTTP shares web settings
  61. OnInitPage = GetSystemSettings()
  62. End Function
  63. '---------------------------------------------------------------------
  64. 'Function: OnPostBackPage()
  65. 'Description: Called to signal that the page has been posted-back.
  66. 'Input Variables: PageIn,EventArg
  67. 'Output Variables: PageIn,EventArg
  68. 'Returns: True/False
  69. 'Global Variables: F_(*)
  70. '---------------------------------------------------------------------
  71. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  72. Call SA_TraceOut( SOURCE_FILE, "OnPostBackPage")
  73. 'Get the values from hidden variables
  74. F_strradIPAdd = Request.Form("hdnIPAddressstatus")
  75. F_nport = Request.Form("hdnPort")
  76. If Ucase(F_strradIPAdd) = CONST_ARR_STATUS_TRUE Then
  77. F_strIPAddress=""
  78. Else
  79. F_strIPAddress = Request.Form("hdnIPAddress")
  80. End If
  81. If Ucase(F_strradIPAdd) = CONST_ARR_STATUS_TRUE Then
  82. F_strAll_IPAddress = CONST_ARR_STATUS_CHECKED
  83. F_strJustthis_IPAddress =""
  84. Else
  85. F_strJustthis_IPAddress = CONST_ARR_STATUS_CHECKED
  86. F_strAll_IPAddress = ""
  87. End if
  88. OnPostBackPage = True
  89. End Function
  90. '---------------------------------------------------------------------
  91. 'Function: OnServeTabbedPropertyPage()
  92. 'Description: Called when the content needs to send
  93. 'Input Variables: PageIn,EventArg,iTab,bIsVisible
  94. 'Output Variables: PageIn,EventArg
  95. 'Returns: True/False
  96. 'Global Variables: idTabGeneral
  97. '---------------------------------------------------------------------
  98. Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  99. ByVal iTab, _
  100. ByVal bIsVisible, ByRef EventArg)
  101. Const CONST_TAB_INDEX = 0
  102. '
  103. ' Emit Web Framework required functions
  104. If ( iTab = CONST_TAB_INDEX ) Then
  105. Call ServeCommonJavaScript()
  106. End If
  107. '
  108. ' Emit content for the requested tab
  109. Select Case iTab
  110. Case iTabGeneral
  111. Call ServeTabGeneral(PageIn, bIsVisible)
  112. Case Else
  113. 'Nothing
  114. End Select
  115. OnServeTabbedPropertyPage = TRUE
  116. End Function
  117. '---------------------------------------------------------------------
  118. 'Function: OnSubmitPage()
  119. 'Description: Called when the page has been submitted for processing.
  120. 'Input Variables: PageIn,EventArg
  121. 'Output Variables: PageIn,EventArg
  122. 'Returns: True/False
  123. 'Global Variables: G_objAdminService,G_objService,L_WMI_CONNECTIONFAIL_ERRORMESSAGE,
  124. ' CONST_WMI_IIS_NAMESPACE, CONST_WMI_WIN32_NAMESPACE
  125. '---------------------------------------------------------------------
  126. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  127. Err.Clear
  128. On Error Resume Next
  129. 'Connecting to the WMI server
  130. Set G_objHTTPService = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  131. Set G_objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  132. If Err.number <> 0 Then
  133. Call SA_ServeFailurePage (L_WMICONNECTIONFAILED_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  134. OnSubmitPage = False
  135. End if
  136. 'To set the HTTP shares web settings
  137. OnSubmitPage = SetHTTPConfig(G_objHTTPService,G_objService)
  138. End Function
  139. '---------------------------------------------------------------------
  140. 'Function: OnClosePage()
  141. 'Description: Called when the page is about to be closed.
  142. 'Input Variables: PageIn,EventArg
  143. 'Output Variables: None
  144. 'Returns: True/False
  145. 'Global Variables: None
  146. '---------------------------------------------------------------------
  147. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  148. OnClosePage = TRUE
  149. End Function
  150. '-------------------------------------------------------------------------
  151. 'Function: ServeTabGeneral()
  152. 'Description: For displaying outputs HTML for tab General to the user
  153. 'Input Variables: PageIn,bIsVisible
  154. 'Output Variables: PageIn
  155. 'Returns: gc_ERR_SUCCESS
  156. 'Global Variables: F_(*),L_(*)
  157. '-------------------------------------------------------------------------
  158. Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible)
  159. If (bIsVisible) Then
  160. %>
  161. <table border=0>
  162. <tr>
  163. <td nowrap class = "TasksBody" colspan =2>
  164. <%=L_HTTPUSAGE_TEXT%>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td class = "TasksBody" colspan =2>
  169. &nbsp;
  170. </td>
  171. </tr>
  172. <tr>
  173. <td class = "TasksBody">
  174. &nbsp;
  175. </td>
  176. <td nowrap class = "TasksBody" >
  177. <INPUT TYPE=RADIO VALUE="YES" CLASS="FormField" NAME=radIPADDRESS <%=Server.HTMLEncode(F_strAll_IPAddress)%> onClick="EnableControls(false)">&nbsp;&nbsp; <%=L_ALLIPADDRESS_TEXT%>
  178. </td>
  179. </tr>
  180. <tr>
  181. <td class = "TasksBody"></td>
  182. <td nowrap class = "TasksBody" colspan="1">
  183. <input type=radio value="NO" class="FormField" name=radIPADDRESS <%=Server.HTMLEncode(F_strJustthis_IPAddress)%> onClick="EnableControls(true)" >&nbsp;&nbsp; <%=L_JUSTTHIS_IP_ADDRESS_TEXT%>
  184. </td>
  185. </tr>
  186. <tr>
  187. <td class = "tasksbody" colspan="2">
  188. </td>
  189. </tr>
  190. <tr>
  191. <td class = "TasksBody">
  192. &nbsp;
  193. </td>
  194. <td class = "TasksBody" colspan="3"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  195. <select name="cboIPAddress" class="FormField" style="WIDTH:180px" >
  196. <% GetSystemNICConfig F_strIPAddress %>
  197. </select>
  198. </td>
  199. </tr>
  200. <tr>
  201. <td class = "TasksBody">
  202. &nbsp;
  203. </td>
  204. <td nowrap class = "TasksBody">
  205. <%=L_PORT_TEXT %>
  206. </td>
  207. </tr>
  208. <tr>
  209. <td class = "TasksBody"></td>
  210. <td class = "TasksBody">
  211. <input type="text" name="txtPort" class="FormField" size="10" maxlength = "5" value="<%=F_nport%>" OnKeypress="javascript:checkKeyforNumbers(this);" >
  212. </td>
  213. </tr>
  214. <tr>
  215. <td class = "TasksBody" colspan =2>
  216. &nbsp;
  217. </td>
  218. </tr>
  219. <tr>
  220. <td nowrap class = "TasksBody" colspan =2>
  221. <%=L_HTTPNOTE_TEXT%>
  222. </td>
  223. </tr>
  224. </table>
  225. <input type=hidden name=hdnIPAddress value ="<%=F_strIPAddress%>">
  226. <input type=hidden name=hdnPort value ="<%=F_nport%>">
  227. <input type=hidden name=hdnIPAddressstatus value ="<%=F_strradIPAdd%>">
  228. <%
  229. End If
  230. ServeTabGeneral = gc_ERR_SUCCESS
  231. End Function
  232. '-------------------------------------------------------------------------
  233. 'Function: ServeCommonJavaScript
  234. 'Description: Serves in initializing the values,setting the form
  235. ' data and validating the form values
  236. 'Input Variables: None
  237. 'Output Variables: None
  238. 'Returns: True/False
  239. 'Global Variables: L_(*)
  240. '-------------------------------------------------------------------------
  241. Function ServeCommonJavaScript()
  242. %>
  243. <SCRIPT language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js"></SCRIPT>
  244. <SCRIPT language="JavaScript">
  245. var CONST_ARR_INDEX_ALL_IP = 0
  246. var CONST_ARR_INDEX_JUST_THIS_IP = 1
  247. // Init Function calls the EnableControls function to enable or disable the controls for the first time
  248. function Init()
  249. {
  250. if(document.frmTask.radIPADDRESS[CONST_ARR_INDEX_ALL_IP].checked)
  251. EnableControls(false)
  252. else if(document.frmTask.radIPADDRESS[CONST_ARR_INDEX_JUST_THIS_IP].checked)
  253. EnableControls(true)
  254. }
  255. // Hidden Values are updated in ValidatePage function
  256. function ValidatePage()
  257. {
  258. document.frmTask.hdnIPAddress.value = document.frmTask.cboIPAddress.value
  259. document.frmTask.hdnPort.value = document.frmTask.txtPort.value
  260. if (document.frmTask.radIPADDRESS[CONST_ARR_INDEX_ALL_IP].checked)
  261. document.frmTask.hdnIPAddressstatus.value = document.frmTask.radIPADDRESS[CONST_ARR_INDEX_ALL_IP].value
  262. else if(document.frmTask.radIPADDRESS[CONST_ARR_INDEX_JUST_THIS_IP].checked)
  263. document.frmTask.hdnIPAddressstatus.value = document.frmTask.radIPADDRESS[CONST_ARR_INDEX_JUST_THIS_IP].value
  264. //If port is left blank display error
  265. if (document.frmTask.txtPort.value == "")
  266. {
  267. SA_DisplayErr('<%=Server.HtmlEncode(SA_EscapeQuotes(L_ENTERPORTNUMBER_ERRORMESSAGE)) %>');
  268. document.frmTask.onkeypress = ClearErr
  269. return false;
  270. }
  271. //If port number is less than 1 or greater then 65535 display error
  272. var MAX_PORT_NO = 65535
  273. var MIN_PORT_NO = 1
  274. if (document.frmTask.txtPort.value > MAX_PORT_NO || document.frmTask.txtPort.value < MIN_PORT_NO)
  275. {
  276. SA_DisplayErr('<%=Server.HtmlEncode(SA_EscapeQuotes(L_VALIDENTERPORTNUMBER_ERRORMESSAGE)) %>');
  277. document.frmTask.onkeypress = ClearErr
  278. return false;
  279. }
  280. return true;
  281. }
  282. //Dummy function for the Framework.
  283. function SetData()
  284. {
  285. }
  286. // EnableControls Function is to enable or disable the combo box depending on radio button value
  287. function EnableControls(blnFlag)
  288. {
  289. if (blnFlag)
  290. {
  291. document.frmTask.cboIPAddress.disabled = false;
  292. }
  293. else
  294. {
  295. document.frmTask.cboIPAddress.disabled =true;
  296. }
  297. }
  298. </SCRIPT>
  299. <%
  300. End Function
  301. '-------------------------------------------------------------------------
  302. 'Function name: SetHTTPConfig()
  303. 'Description: Serves in configuring IP address and port of HTTP shares web site
  304. 'Input Variables: G_objHTTPService, G_objService
  305. 'Output Variables: True or false
  306. 'Returns: None
  307. 'Global Variables: F_strIPAddress,F_nport,L_(*)
  308. 'This function configures the IP address and port of HTTP shares web site
  309. '-------------------------------------------------------------------------
  310. Function SetHTTPConfig(G_objHTTPService,G_objService)
  311. Err.Clear
  312. On Error Resume Next
  313. Dim objHTTPService 'Object to get instance of HTTP service
  314. Dim objService 'Object to get instance of CIMV2
  315. Dim objNetWorkCon 'To get instance of IIs_WebServerSetting class
  316. Dim objServerSetting 'To get instances of IIs_WebServerSetting class
  317. Dim objNACCollection 'To get instance of IIs_WebServerSetting where site is other than HTTP Shares
  318. Dim objinst 'To get instances of IIs_WebServerSetting where site is other than HTTP shares
  319. Dim nport 'Port number
  320. Dim strWMIpath 'WMI query to get HTTP shares web site
  321. Dim strServerSettings 'To store the values obtained from ServerBindings property
  322. Dim strIPAddress 'String to store the IP address
  323. Dim arrWinsSrv 'Array to store the IP address and port number
  324. Dim arrIPAdd 'Array to store the port number
  325. Dim nIPCount 'Count for getting the IP address and port number
  326. Dim arrPort 'Array to store the port number
  327. Dim strReturnURL 'Stores Return URL
  328. Dim objConfiguredIPs 'To get instance of win32_NetworkAdapterConfiguration
  329. Dim objNICIP 'To get instances of win32_NetworkAdapterConfiguration
  330. Dim strNICQuery 'Query to get all IP addresses
  331. Dim nCount 'Count for getting the IP address and port number
  332. Dim arrIPList(13) 'Array to store the IP addresses for all NIC cards
  333. Dim nIPlistCount 'Count to get IP addresses for all NIC cards
  334. Dim strIPFlag 'Boolean value to store the validity of IP address
  335. Dim strHTTPWebSite 'HTTP shares web site name
  336. Dim strFTPSite 'FTP site name
  337. Dim strFTPpath 'FTP site path
  338. Dim nFTPIPCount 'Count for getting the IP address and port number for FTP site
  339. Dim strFTPServerBindings 'To store the values obtained from SeverBindings property for FTP site
  340. Dim arrFTPWinsSrv 'Array to store the IP address and port for FTP site
  341. Dim arrFTPIPAdd 'Array to store the IP address FTP site
  342. Dim arrFTPPort 'Array to store the port for FTP site
  343. Dim objFTPinst 'Gettings instances for FTP site
  344. Dim objFTPInstances 'Object instance for FTP site
  345. Const CONST_ARR_INDEX_IP = 0 'For IP address
  346. Const CONST_ARR_INDEX_PORT = 1 'For port number
  347. Call SA_TraceOut( SOURCE_FILE, "SetHTTPConfig")
  348. 'Getting the return URL
  349. strReturnURL = "/tasks.asp?tab1="
  350. 'FTP site name
  351. strFTPSite = "MSFTPSVC/1"
  352. 'Assign global objects to local variables
  353. Set objHTTPService = G_objHTTPService
  354. Set objService = G_objService
  355. 'Get the HTTP shares web site name
  356. strHTTPWebSite = GetHTTPWebSite(objHTTPService)
  357. 'To get instances of Web sites other than HTTP Shares
  358. strWMIpath = "select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where Name != " & Chr(34)& strHTTPWebSite & Chr(34)
  359. Set objNACCollection = objHTTPService.ExecQuery(strWMIpath)
  360. If Err.Number <> 0 Then
  361. Call SA_SetErrMsg (L_IIS_WEBSERVERCONNECTION_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  362. SetHTTPConfig = false
  363. Exit Function
  364. End If
  365. 'If other web site is configured with the same IP address and port number display error
  366. For each objinst in objNACCollection
  367. If IsArray(objinst.ServerBindings) Then
  368. For nIPCount = 0 to ubound(objinst.ServerBindings)
  369. strServerSettings = objinst.ServerBindings(nIPCount)
  370. if IsIIS60Installed Then
  371. If IsObject(objinst.ServerBindings(nIPCount)) Then
  372. arrIPAdd = objinst.ServerBindings(nIPCount).IP
  373. arrPort = objinst.ServerBindings(nIPCount).Port
  374. If F_strIPAddress <> "" then
  375. If arrIPAdd = F_strIPAddress and arrPort = F_nport and IsWebsiteNotStopped(objinst.name) then
  376. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  377. SetHTTPConfig = False
  378. Exit Function
  379. End if
  380. Else
  381. If arrPort = F_nport and IsWebsiteNotStopped(objinst.name) then
  382. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  383. SetHTTPConfig = False
  384. Exit Function
  385. End if
  386. End if ' If F_strIPAddress <> ""
  387. End If 'If IsObject(...)
  388. Else ' If not 6.0 installed
  389. If strServerSettings <> "" then
  390. 'split the strServerSettings array to get the IP address and port
  391. arrWinsSrv = split(strServerSettings,":")
  392. arrIPAdd = arrWinsSrv(CONST_ARR_INDEX_IP)
  393. arrPort = arrWinsSrv(CONST_ARR_INDEX_PORT)
  394. If F_strIPAddress <> "" then
  395. If arrIPAdd = F_strIPAddress and arrPort = F_nport and IsWebsiteNotStopped(objinst.name) then
  396. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  397. SetHTTPConfig = False
  398. Exit Function
  399. End if
  400. Else
  401. If arrPort = F_nport and IsWebsiteNotStopped(objinst.name) then
  402. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  403. SetHTTPConfig = False
  404. Exit Function
  405. End if
  406. End if ' If F_strIPAddress <> ""
  407. End if
  408. End If 'If IsIIS60Installed
  409. Next
  410. End if
  411. Next
  412. 'Display error if not able to verify with other web sites IP address and port number
  413. If Err.Number <> 0 Then
  414. Call SA_SetErrMsg (L_FAILEDTO_VERIFY_IPADD_PORT_ERRORMESSAGE)
  415. SetHTTPConfig = false
  416. Exit Function
  417. End If
  418. 'To get the instance of FTP server settings
  419. strFTPpath = "select * from " & GetIISWMIProviderClassName("IIS_FtpServerSetting") & " where Name = " & chr(34) & strFTPSite & chr(34)
  420. Set objFTPInstances = objHTTPService.ExecQuery(strFTPpath)
  421. If Err.Number <> 0 Then
  422. Call SA_SetErrMsg (L_IIS_WEBSERVERCONNECTION_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  423. SetHTTPConfig = false
  424. Exit Function
  425. End If
  426. 'Display error if HTTP shares site is configured at same IP address and port number as FTP site
  427. For each objFTPinst in objFTPInstances
  428. If IsArray(objFTPinst.ServerBindings) Then
  429. For nFTPIPCount = 0 to ubound(objFTPinst.ServerBindings)
  430. strFTPServerBindings = objFTPinst.ServerBindings(nFTPIPCount)
  431. If IsIIS60Installed Then
  432. If IsObject(objFTPinst.ServerBindings(nFTPIPCount)) Then
  433. arrFTPIPAdd = objFTPinst.ServerBindings(nFTPIPCount).IP
  434. arrFTPPort = objFTPinst.ServerBindings(nFTPIPCount).Port
  435. If F_strIPAddress <> "" then
  436. If arrFTPIPAdd = F_strIPAddress and arrFTPPort = F_nport then
  437. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  438. SetHTTPConfig = False
  439. Exit Function
  440. ElseIf arrFTPIPAdd = "" and arrFTPPort = F_nport then
  441. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  442. SetHTTPConfig = False
  443. Exit Function
  444. End if
  445. Else
  446. If arrFTPPort = F_nport then
  447. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  448. SetHTTPConfig = False
  449. Exit Function
  450. End if
  451. End if 'If F_strIPAddress <> ""
  452. End If 'If IsObject(...)
  453. Else
  454. If strFTPServerBindings <> "" then
  455. 'split the strFTPServerBindings array to get the IP address and port
  456. arrFTPWinsSrv = split(strFTPServerBindings,":")
  457. arrFTPIPAdd = arrFTPWinsSrv(CONST_ARR_INDEX_IP)
  458. arrFTPPort = arrFTPWinsSrv(CONST_ARR_INDEX_PORT)
  459. If F_strIPAddress <> "" then
  460. If arrFTPIPAdd = F_strIPAddress and arrFTPPort = F_nport then
  461. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  462. SetHTTPConfig = False
  463. Exit Function
  464. ElseIf arrFTPIPAdd = "" and arrFTPPort = F_nport then
  465. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  466. SetHTTPConfig = False
  467. Exit Function
  468. End if
  469. Else
  470. If arrFTPPort = F_nport then
  471. Call SA_SetErrMsg (L_IIS_WEBSERVER_COULDNOTSET_ERRORMESSAGE)
  472. SetHTTPConfig = False
  473. Exit Function
  474. End if
  475. End if 'If F_strIPAddress <> ""
  476. End If ' If strFTPServerBindings <> ""
  477. End If ' If IsIIS60Installed
  478. Next
  479. End If
  480. Next
  481. 'Display error if not able to verify with FTP site IP address and port number
  482. If Err.Number <> 0 Then
  483. Call SA_SetErrMsg (L_FAILEDTO_VERIFY_IPADD_PORT_ERRORMESSAGE)
  484. SetHTTPConfig = false
  485. Exit Function
  486. End If
  487. 'Release objects
  488. Set objFTPinst = Nothing
  489. Set objFTPInstances = Nothing
  490. 'Assigning values to local variables
  491. strIPAddress = F_strIPAddress
  492. nport = F_nport
  493. 'To get instance of win32_NetworkAdapterConfiguration class
  494. strNICQuery = "select * from win32_NetworkAdapterConfiguration Where IPEnabled = true"
  495. Set objConfiguredIPs = objService.ExecQuery(strNICQuery)
  496. If Err.number <> 0 then
  497. Call SA_ServeFailurePage (L_FAILEDTOGET_IPADDRESS_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  498. SetHTTPConfig = false
  499. Exit Function
  500. End If
  501. 'Getting the NIC IP addresses
  502. For each objNICIP in objConfiguredIPs
  503. arrIPList(nIPlistCount) = objNICIP.IPAddress(nCount)
  504. nIPlistCount = nIPlistCount+1
  505. Next
  506. 'Release objects
  507. Set objConfiguredIPs = nothing
  508. Set objNICIP = nothing
  509. 'To check whether the selected IP address is a valid IP address
  510. For nCount = 0 to nIPlistCount-1
  511. If strIPAddress = arrIPList(nCount) or strIPAddress = "" Then
  512. strIPFlag = true
  513. Exit For
  514. else
  515. strIPFlag = false
  516. End If
  517. Next
  518. 'If selected Ip address is invalid display error
  519. If strIPFlag = false then
  520. Call SA_SetErrMsg (L_INVALID_IPADDRESS_ERRORMESSAGE)
  521. SetHTTPConfig = false
  522. Exit Function
  523. End if
  524. 'Getting the IIS_WEB Server Setting instance
  525. Set objNetWorkCon = objHTTPService.ExecQuery("Select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where Name=" & Chr(34)& strHTTPWebSite & Chr(34))
  526. If Err.Number <> 0 Then
  527. Call SA_SetErrMsg (L_IIS_WEBSERVERCONNECTION_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  528. SetHTTPConfig = false
  529. Exit Function
  530. End If
  531. 'Loop to set the IP address and port
  532. For each objServerSetting in objNetWorkCon
  533. If IsIIS60Installed Then
  534. Dim arrObjBindings(0)
  535. set arrObjBindings(0) = objHTTPService.Get("ServerBinding").SpawnInstance_
  536. arrObjBindings(0).Port = nport
  537. arrObjBindings(0).IP = strIPAddress
  538. objServerSetting.ServerBindings = arrObjBindings
  539. Else
  540. objServerSetting.ServerBindings = array(strIPAddress & ":" & nport & ":")
  541. End If
  542. objServerSetting.Put_
  543. Next
  544. 'Error while putting the web server settings
  545. If Err.Number <> 0 Then
  546. Call SA_SetErrMsg (L_COULDNOT_IIS_WEBSERVERSETTING_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  547. SetHTTPConfig = false
  548. Exit Function
  549. End If
  550. 'Release the objects
  551. Set objNetWorkCon = nothing
  552. set objinst = nothing
  553. set objNACCollection = nothing
  554. set objServerSetting = nothing
  555. Set objHTTPService = nothing
  556. Set objService = nothing
  557. SetHTTPConfig = TRUE
  558. End Function
  559. '-------------------------------------------------------------------------
  560. 'Function name: GetHTTPWebSite
  561. 'Description: Get HTTP shares web site name
  562. 'Input Variables: objHTTPService
  563. 'Output Variables: None
  564. 'Global Variables: L_(*)
  565. 'Returns: HTTP shares web site name
  566. '-------------------------------------------------------------------------
  567. Function GetHTTPWebSite(objHTTPService)
  568. Err.Clear
  569. On Error Resume Next
  570. Dim strWMIpath 'WMI query
  571. Dim objSiteCollection 'Get instance of IIs_WebServerSetting class
  572. Dim objSite 'Get instances of IIs_WebServerSetting class
  573. Dim objHTTPWebService
  574. Call SA_TraceOut( SOURCE_FILE, "GetHTTPWebSite")
  575. Set objHTTPWebService = objHTTPService
  576. 'XPE only has one website, we display the site as the shared site
  577. If CONST_OSNAME_XPE = GetServerOSName() Then
  578. 'WMI query
  579. strWMIpath = "Select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where Name =" & chr(34) & GetCurrentWebsiteName & chr(34)
  580. Else
  581. 'Constant for the HTTP shares web site
  582. Const CONST_MANAGEDSITENAME = "Shares"
  583. 'WMI query
  584. strWMIpath = "Select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where ServerComment =" & chr(34) & CONST_MANAGEDSITENAME & chr(34)
  585. End If
  586. 'Create instance of IIs_WebServerSetting
  587. Set objSiteCollection = objHTTPWebService.ExecQuery(strWMIpath)
  588. If Err.Number <> 0 Then
  589. Call SA_ServeFailurePage (L_IIS_WEBSERVERCONNECTION_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  590. Exit Function
  591. End If
  592. 'Get the HTTP shares web site name
  593. For each objSite in objSiteCollection
  594. GetHTTPWebSite = objSite.Name
  595. Exit For
  596. Next
  597. 'If HTTP shares site name is empty display error
  598. If GetHTTPWebSite = "" Then
  599. Call SA_ServeFailurePage (L_COULDNOT_SHARES_WEBSITE_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  600. Exit Function
  601. End If
  602. 'Release objects
  603. Set objSite = Nothing
  604. Set objSiteCollection = Nothing
  605. Set objHTTPWebService = Nothing
  606. End Function
  607. '-------------------------------------------------------------------------
  608. 'Subroutine name: GetSystemNICConfig
  609. 'Desription: Gets all the NIC IP's from the system
  610. 'Input Variables: F_strIPAddress
  611. 'Output variables: None
  612. 'Global Variables: G_objService,CONST_WMI_WIN32_NAMESPACE,L_(*)
  613. '-------------------------------------------------------------------------
  614. Sub GetSystemNICConfig(F_strIPAddress)
  615. Err.clear
  616. On Error Resume Next
  617. Dim objConfiguredIPs 'To get instance of win32_NetworkAdapterConfiguration
  618. Dim objNICIP 'To get instances of win32_NetworkAdapterConfiguration
  619. Dim strNICQuery 'WMI query
  620. Dim nCount 'Count to get IP address for all NIC cards
  621. Dim arrIPList(13) 'Array to store all the IP addresses
  622. Call SA_TraceOut( SOURCE_FILE, "GetSystemNICConfig")
  623. 'Connecting to the WMI server
  624. Set G_objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE)
  625. If Err.number <> 0 Then
  626. Call SA_ServeFailurePage (L_WMICONNECTIONFAILED_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  627. Exit Sub
  628. End if
  629. 'WMI query
  630. strNICQuery = "select * from win32_NetworkAdapterConfiguration Where IPEnabled = true"
  631. 'Getting instance of win32_NetworkAdapterConfiguration
  632. Set objConfiguredIPs = G_objService.ExecQuery(strNICQuery)
  633. If Err.number <> 0 then
  634. Call SA_ServeFailurePage (L_FAILEDTOGET_IPADDRESS_ERRORMESSAGE & " (" & HEX(Err.Number) & ")" )
  635. Exit Sub
  636. End If
  637. 'Populate the IP address combo box
  638. For each objNICIP in objConfiguredIPs
  639. If IsArray(objNICIP.IPAddress) Then
  640. For nCount = 0 to ubound(objNICIP.IPAddress)
  641. Redim arrIPList(ubound(objNICIP.IPAddress))
  642. arrIPList(nCount) = objNICIP.IPAddress(nCount)
  643. If arrIPList(nCount) <> "" Then
  644. If (arrIPList(nCount) = F_strIPAddress ) Then
  645. Response.Write "<OPTION VALUE='" & arrIPList(nCount) &"' SELECTED >" & arrIPList(nCount) & "</OPTION>"
  646. Else
  647. Response.Write "<OPTION VALUE='" & arrIPList(nCount) &"' >" & arrIPList(nCount) & "</OPTION>"
  648. End IF
  649. End If
  650. Next
  651. End If
  652. Next
  653. 'Release objects
  654. Set objConfiguredIPs = nothing
  655. Set objNICIP = nothing
  656. End Sub
  657. '-------------------------------------------------------------------------
  658. 'Function name: GetSystemSettings
  659. 'Description: Serves in getting the IP address(es) and port number's
  660. ' from System for HTTP shares web site
  661. 'Input Variables: None
  662. 'Output Variables: None
  663. 'Returns: True/False
  664. 'Global Variables: G_objHTTPService, CONST_WMI_IIS_NAMESPACE, L_(*)
  665. '-------------------------------------------------------------------------
  666. Function GetSystemSettings()
  667. Err.Clear
  668. On Error resume Next
  669. Dim objNACCollection 'Object to get WMI connection
  670. Dim objinst 'Getting instances of IIs_WebServerSetting
  671. Dim arrWinsSrv 'Array to store the IP address and port number
  672. Dim arrIPAdd 'Array to store the IP address
  673. Dim arrPort 'Array to store the port
  674. Dim nIPCount 'Count for getting the IP address and port number
  675. Dim strServerSettings 'To store the values obtained from ServerBindings property
  676. Dim strHTTPWebSite 'HTTP shares web site name
  677. Const CONST_ARR_INDEX_IP = 0 'For IP address
  678. Const CONST_ARR_INDEX_PORT = 1 'For port number
  679. Call SA_TraceOut( SOURCE_FILE, "GetSystemSettings")
  680. 'Connecting to the WMI server
  681. Set G_objHTTPService = GetWMIConnection(CONST_WMI_IIS_NAMESPACE)
  682. 'Get the HTTP shares web site name
  683. strHTTPWebSite = GetHTTPWebSite(G_objHTTPService)
  684. 'Getting the HTTP shares web server setting instance
  685. Set objNACCollection = G_objHTTPService.ExecQuery("Select * from " & GetIISWMIProviderClassName("IIs_WebServerSetting") & " where Name = " & Chr(34) & strHTTPWebSite & Chr(34))
  686. If Err.Number <> 0 Then
  687. Call SA_ServeFailurePage (L_IIS_WEBSERVERCONNECTION_ERRORMESSAGE & " (" & HEX(Err.Number) & ")")
  688. GetSystemSettings = False
  689. Exit Function
  690. End If
  691. '
  692. 'ServerBindings property is changed in IIS 60 provider
  693. '
  694. 'Getting the IP address and port number from server bindings property
  695. For each objinst in objNACCollection
  696. If IsArray(objinst.ServerBindings) Then
  697. For nIPCount = 0 to ubound(objinst.ServerBindings)
  698. strServerSettings = objinst.ServerBindings(nIPCount)
  699. If IsIIS60Installed Then
  700. 'In 6.0 ServerBindings is an object
  701. If IsObject(objinst.ServerBindings(nIPCount)) Then
  702. arrIPAdd = objinst.ServerBindings(nIPCount).IP
  703. arrPort = objinst.ServerBindings(nIPCount).Port
  704. F_strIPAddress = objinst.ServerBindings(nIPCount).IP
  705. F_nport = objinst.ServerBindings(nIPCount).Port
  706. End If
  707. Else
  708. If strServerSettings <> "" then
  709. 'split the strServerSettings array to get the IP address and port number
  710. arrWinsSrv = split(strServerSettings,":")
  711. arrIPAdd = arrWinsSrv(CONST_ARR_INDEX_IP)
  712. arrPort = arrWinsSrv(CONST_ARR_INDEX_PORT)
  713. F_strIPAddress = arrWinsSrv(CONST_ARR_INDEX_IP)
  714. F_nport = arrWinsSrv(CONST_ARR_INDEX_PORT)
  715. End if
  716. End If 'If IsIIS60Installed
  717. Next
  718. End If
  719. Next
  720. 'Error in getting the server IP address and port number
  721. If Err.Number <> 0 Then
  722. Call SA_ServeFailurePage (L_COULDNOT_IIS_WEBSERVER_OBJECT_ERRORMESSAGE & " (" & HEX(Err.Number) & ")")
  723. GetSystemSettings = False
  724. Exit Function
  725. End If
  726. 'Set the Radion button status depending on the system settings
  727. If arrIPAdd = "" then
  728. F_strAll_IPAddress = CONST_ARR_STATUS_CHECKED
  729. F_strJustthis_IPAddress =""
  730. F_strradIPAdd = CONST_ARR_STATUS_TRUE
  731. Else
  732. F_strJustthis_IPAddress = CONST_ARR_STATUS_CHECKED
  733. F_strAll_IPAddress = ""
  734. F_strradIPAdd = CONST_ARR_STATUS_FALSE
  735. End if
  736. 'Release objects
  737. Set objinst = Nothing
  738. Set objNACCollection = Nothing
  739. GetSystemSettings = True
  740. End Function
  741. %>