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.

817 lines
25 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' FTP_MasterSettings.asp: Set FTP Master Settings Values
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 08-11-2000 Created date
  11. ' 15-01-2001 Modified for new Framework
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp"--->
  15. <!-- #include virtual="/admin/wsa/inc_wsa.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Form Variables
  19. '-------------------------------------------------------------------------
  20. Dim F_FTPEnabled 'Whether FTP service is enabled (started) or not
  21. Dim F_selectDirListStyle 'Directory Listing Style
  22. Dim F_FTPMaxCon 'Maximum Connections
  23. Dim F_FTPCon_Timeout 'Conection Time out
  24. Dim FTPInstalled 'Holds a boolean value to check whether FTP
  25. 'service is installed
  26. '-------------------------------------------------------------------------
  27. ' Global Variables
  28. '-------------------------------------------------------------------------
  29. Dim G_objService
  30. Dim G_objSites
  31. '-------------------------------------------------------------------------
  32. ' Start of localization content
  33. '-------------------------------------------------------------------------
  34. Dim L_FTPTASKTITLETEXT
  35. Dim L_WEBROOTDIR
  36. Dim L_ENABLEFTP
  37. Dim L_DIRLISTINGSTYLE
  38. Dim L_MAX_CONNECTIONSTEXT
  39. Dim L_CON_TIMEOUT
  40. Dim L_SECONDSTEXT
  41. Dim L_NOT_NTFS_DRIVE_ERRORMESSAGE
  42. Dim L_FAILED_CREATE_DIR_ERRORMESSAGE
  43. Dim L_INVALID_DRIVE_ERRORMESSAGE
  44. Dim L_UNABLE_TO_SETREGISTRY
  45. Dim L_UNABLE_TO_SETMASTERSETTINGS
  46. Dim L_CONLIMIT_ERRORMESSAGE
  47. Dim L_CONTIMEOUT_ERRORMESSAGE
  48. Dim L_UNABLETOCREATE_KEY_ERRORMESSAGE
  49. Dim L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE
  50. Dim L_FAIL_TO_GET_FTPSITEROOT_DIR
  51. Dim L_INVALID_DIR_FORMAT_ERRORMESSAGE
  52. Dim L_INVALID_DIR_ERRORMESSAGE
  53. Dim L_DIRPATHEMPTY_ERRORMESSAGE
  54. Dim L_FTPNOTINSTALLED_ERRORMESSAGE
  55. Dim L_ENABLE_FTP_SERVICE
  56. Dim L_ID_NOTEMPTY_ERROR_MESSAGE
  57. Dim L_SITE_IDENTIFIER_EMPTY_TEXT
  58. Dim L_CREATEADMINFTPSERVER_ERRORMESSAGE
  59. L_FTPTASKTITLETEXT = GetLocString("GeneralSettings.dll", "4042001A", "")
  60. L_WEBROOTDIR = GetLocString("GeneralSettings.dll", "4042001B", "")
  61. L_ENABLEFTP = GetLocString("GeneralSettings.dll", "4042001D", "")
  62. L_DIRLISTINGSTYLE = GetLocString("GeneralSettings.dll", "4042001F", "")
  63. L_MAX_CONNECTIONSTEXT = GetLocString("GeneralSettings.dll", "40420008", "")
  64. L_CON_TIMEOUT = GetLocString("GeneralSettings.dll", "40420021", "")
  65. L_SECONDSTEXT = GetLocString("GeneralSettings.dll", "40420006", "")
  66. L_NOT_NTFS_DRIVE_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042000D", "")
  67. L_FAILED_CREATE_DIR_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042000E", "")
  68. L_INVALID_DRIVE_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420022", "")
  69. L_UNABLE_TO_SETREGISTRY = GetLocString("GeneralSettings.dll", "C0420055", "")
  70. L_UNABLE_TO_SETMASTERSETTINGS = GetLocString("GeneralSettings.dll", "C0420054", "")
  71. L_CONLIMIT_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042000B", "")
  72. L_CONTIMEOUT_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420053", "")
  73. L_UNABLETOCREATE_KEY_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420018", "")
  74. L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420019", "")
  75. L_FAIL_TO_GET_FTPSITEROOT_DIR = GetLocString("GeneralSettings.dll", "C0420023", "")
  76. L_INVALID_DIR_FORMAT_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "40420004", "")
  77. L_INVALID_DIR_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042004B", "")
  78. L_DIRPATHEMPTY_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C042004C", "")
  79. L_FTPNOTINSTALLED_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "C0420058", "")
  80. L_ENABLE_FTP_SERVICE = GetLocString("GeneralSettings.dll", "4042005B", "")
  81. L_CREATEADMINFTPSERVER_ERRORMESSAGE = GetLocString("GeneralSettings.dll", "4042005D", "")
  82. '-------------------------------------------------------------------------
  83. 'END of localization content
  84. '-------------------------------------------------------------------------
  85. 'Create property page
  86. Dim rc
  87. Dim page
  88. rc=SA_CreatePage(L_FTPTASKTITLETEXT,"",PT_PROPERTY,page)
  89. 'Serve the page
  90. If(rc=0) then
  91. SA_ShowPage(page)
  92. End if
  93. '-------------------------------------------------------------------------
  94. 'Function: OnInitPage()
  95. 'Description: Called to signal first time processing for this page.
  96. ' Use this method to do first time initialization tasks
  97. 'Input Variables: PageIn,EventArg
  98. 'Output Variables: None
  99. 'Returns: True/False
  100. 'Global Variables: None
  101. '-------------------------------------------------------------------------
  102. Public Function OnInitPage(ByRef PageIn,ByRef EventArg)
  103. InitObjects()
  104. if FTPInstalled = false then
  105. ServeFailurePage L_FTPNOTINSTALLED_ERRORMESSAGE ,sReturnURL
  106. end if
  107. SetVariablesFromSystem()
  108. OnInitPage = True
  109. End Function
  110. '-------------------------------------------------------------------------
  111. 'Function: OnServePropertyPage()
  112. 'Description: Called when the page needs to be served.Use this
  113. ' method to serve content
  114. 'Input Variables: PageIn,EventArg
  115. 'Output Variables: None
  116. 'Returns: True/False
  117. 'Global Variables: None
  118. '-------------------------------------------------------------------------
  119. Public Function OnServePropertyPage(ByRef PageIn,Byref EventArg)
  120. Call ServeCommonJavaScript()
  121. Call ServePage()
  122. OnServePropertyPage = True
  123. End Function
  124. '-------------------------------------------------------------------------
  125. 'Function: OnPostBackPage()
  126. 'Description: Called to signal that the page has been posted-back.
  127. 'Input Variables: PageIn,EventArg
  128. 'Output Variables: None
  129. 'Returns: True/False
  130. 'Global Variables: None
  131. '-------------------------------------------------------------------------
  132. Public Function OnPostBackPage(ByRef PageIn ,ByRef EventArg)
  133. OnPostBackPage = True
  134. End Function
  135. '-------------------------------------------------------------------------
  136. 'Function: OnSubmitPage()
  137. 'Description: Called when the page has been submitted for processing.
  138. ' Use this method to process the submit request.
  139. 'Input Variables: PageIn,EventArg
  140. 'Output Variables: None
  141. 'Returns: True/False
  142. 'Global Variables: None
  143. '-------------------------------------------------------------------------
  144. Public Function OnSubmitPage(ByRef PageIn ,ByRef EventArg)
  145. OnSubmitPage = ServeVariablesFromForm()
  146. End Function
  147. '-------------------------------------------------------------------------
  148. 'Function: OnClosePage()
  149. 'Description: Called when the page is about closed.Use this method
  150. ' to perform clean-up processing
  151. 'Input Variables: PageIn,EventArg
  152. 'Output Variables: None
  153. 'Returns: True/False
  154. 'Global Variables: None
  155. '-------------------------------------------------------------------------
  156. Public Function OnClosePage(ByRef PageIn ,ByRef EventArg)
  157. OnClosePage = TRUE
  158. End Function
  159. '-------------------------------------------------------------------------
  160. 'Function: ServeCommonJavaScript
  161. 'Description: Serves in initialiging the values,setting the form
  162. ' data and validating the form values
  163. 'Input Variables: None
  164. 'Output Variables: None
  165. 'Returns: True/False
  166. 'Global Variables: None
  167. '-------------------------------------------------------------------------
  168. Function ServeCommonJavaScript()
  169. %>
  170. <!-- #include virtual="/admin/wsa/inc_wsa.js" -->
  171. <script language="JavaScript">
  172. //init function
  173. function Init()
  174. {
  175. var FTPinst = "<%=Server.HTMLEncode(FTPInstalled)%>";
  176. if (FTPinst == "False")
  177. {
  178. document.frmTask.selectDirListStyle.disabled = true;
  179. document.frmTask.txtMaxCon.disabled = true;
  180. document.frmTask.txtConTimeOut.disabled = true;
  181. document.frmTask.selectDirListStyle.disabled = true;
  182. document.frmTask.txtMaxCon.value = "";
  183. document.frmTask.txtConTimeOut.value = "";
  184. document.frmTask.selectDirListStyle.style.backgroundColor = "c0c0c0";
  185. document.frmTask.txtMaxCon.style.backgroundColor = "c0c0c0";
  186. document.frmTask.txtConTimeOut.style.backgroundColor = "c0c0c0";
  187. }
  188. }
  189. //Validates user input
  190. function ValidatePage()
  191. {
  192. var FTPinst = "<%=Server.HTMLEncode(FTPInstalled)%>";
  193. if (FTPinst == "True")
  194. {
  195. var ConTime = document.frmTask.txtConTimeOut.value;
  196. var MaxCon = document.frmTask.txtMaxCon.value;
  197. if( MaxCon =="" )
  198. {
  199. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONLIMIT_ERRORMESSAGE)) %>");
  200. return false;
  201. }
  202. }
  203. var ConTime = document.frmTask.txtConTimeOut.value;
  204. var MaxCon = document.frmTask.txtMaxCon.value;
  205. if(ConTime=="" || ConTime==0)
  206. {
  207. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE))%>");
  208. return false;
  209. }
  210. if(MaxCon=="" || MaxCon == 0)
  211. {
  212. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONLIMIT_ERRORMESSAGE)) %>");
  213. return false;
  214. }
  215. UpdateHiddenVariables();
  216. return true;
  217. }
  218. function checkKeyforValidCharacters(strID)
  219. {
  220. var len = strID.length;
  221. var charAtPos;
  222. if(len > 0)
  223. {
  224. for(var i=0; i<len;i++)
  225. {
  226. charAtPos = strID.charCodeAt(i);
  227. if(charAtPos ==47 || charAtPos == 42 || charAtPos == 63 || charAtPos == 34 || charAtPos == 60 || charAtPos == 62 || charAtPos == 124 || charAtPos == 91 || charAtPos == 93 || charAtPos == 59 || charAtPos == 43 || charAtPos == 61 || charAtPos == 44)
  228. {
  229. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALID_DIR_ERRORMESSAGE))%>");
  230. return false;
  231. }
  232. }
  233. return true;
  234. }
  235. else
  236. {
  237. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_DIRPATHEMPTY_ERRORMESSAGE))%>");
  238. return false;
  239. }
  240. }
  241. function checkforEmptyMaxCon()
  242. {
  243. var strMaxCon = document.frmTask.txtMaxCon.value;
  244. if (strMaxCon == "" )
  245. {
  246. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE)) %>");
  247. document.frmTask.txtMaxCon.focus();
  248. return false;
  249. }
  250. if (strMaxCon == 0 )
  251. {
  252. document.frmTask.txtMaxCon.value =1;
  253. }
  254. }
  255. function checkforEmptyConTimeOut()
  256. {
  257. var strConTimeOut = document.frmTask.txtConTimeOut.value;
  258. if (strConTimeOut == "")
  259. {
  260. SA_DisplayErr("<%=Server.HTMLEncode(SA_EscapeQuotes(L_CONTIMEOUT_ERRORMESSAGE)) %>");
  261. document.frmTask.txtConTimeOut.focus();
  262. return false;
  263. }
  264. if (strConTimeOut == 0)
  265. {
  266. document.frmTask.txtConTimeOut.value = 1;
  267. }
  268. }
  269. function SetData()
  270. {
  271. UpdateHiddenVariables();
  272. }
  273. function UpdateHiddenVariables()
  274. {
  275. document.frmTask.hdnFTPEnabled.value = document.frmTask.chkEnableFTP.checked;
  276. document.frmTask.hdnFTPMaxCon.value = document.frmTask.txtMaxCon.value;
  277. document.frmTask.hdnFTPConTimeout.value = document.frmTask.txtConTimeOut.value;
  278. document.frmTask.hdnFTPListStyle.value = document.frmTask.selectDirListStyle.options[document.frmTask.selectDirListStyle.selectedIndex].value;
  279. }
  280. // Enable FTP clicked
  281. function EnableFtp()
  282. {
  283. EnableOK();
  284. if ( document.frmTask.chkEnableFTP.checked == false )
  285. {
  286. document.frmTask.selectDirListStyle.disabled = true;
  287. document.frmTask.txtMaxCon.disabled = true;
  288. document.frmTask.txtConTimeOut.disabled = true;
  289. }
  290. else
  291. {
  292. document.frmTask.selectDirListStyle.disabled = false;
  293. document.frmTask.txtMaxCon.disabled = false;
  294. document.frmTask.txtConTimeOut.disabled = false;
  295. }
  296. }
  297. </script>
  298. <% End Function
  299. '-------------------------------------------------------------------------
  300. 'Function: ServePage()
  301. 'Description: For displaying outputs HTML to the user
  302. 'Input Variables: None
  303. 'Output Variables: None
  304. 'Returns: None
  305. 'Global Variables: L_DELETE_CONFIRM_TEXT
  306. '-------------------------------------------------------------------------
  307. Function ServePage
  308. %>
  309. </h5><br><BR>
  310. <TABLE border=0 cellPadding=1 cellSpacing=1 style="LEFT: 12px; TOP: 15px" class="TasksBody">
  311. <%
  312. Dim bIsFTPEnabled
  313. bIsFTPEnabled = false
  314. if IsFTPEnabled() Then ' Check if FTP service is running
  315. if IsAdminFTPServerExistAndRunning() Then ' Check if admin FTP server
  316. bIsFTPEnabled = true ' exists and is running
  317. End If
  318. End If
  319. %>
  320. <TR>
  321. <TD width="50%">
  322. &nbsp;&nbsp;&nbsp;
  323. <% if bIsFTPEnabled then%>
  324. <INPUT TYPE=checkbox NAME=chkEnableFTP class="formField" value="true" checked tabIndex=1">
  325. <% else %>
  326. <INPUT TYPE=checkbox NAME=chkEnableFTP class="formField" value="false" tabIndex=1">
  327. <% end if %>
  328. &nbsp;&nbsp;&nbsp;<%=L_ENABLE_FTP_SERVICE%>
  329. </TD>
  330. </TR>
  331. <TR>
  332. <TD>
  333. &nbsp;
  334. </TD>
  335. </TR>
  336. <TR>
  337. <TD>
  338. &nbsp;&nbsp;&nbsp;
  339. <%=L_DIRLISTINGSTYLE%>
  340. </TD>
  341. <TD>
  342. <SELECT name=selectDirListStyle style="HEIGHT: 22px; WIDTH: 85px" tabIndex=3 class="formField" value="<%=F_selectDirListStyle%>">
  343. <% if F_selectDirListStyle = "UNIX" then %>
  344. <OPTION selected value="UNIX">UNIX</OPTION>
  345. <OPTION value="MS-DOS">MS-DOS</OPTION>
  346. <%else%>
  347. <OPTION value="UNIX">UNIX</OPTION>
  348. <OPTION selected value="MS-DOS">MS-DOS</OPTION>
  349. <%end if%>
  350. </SELECT>
  351. </TD>
  352. </TR>
  353. <TR>
  354. <TD>
  355. &nbsp;
  356. </TD>
  357. </TR>
  358. <TR>
  359. <TD>
  360. &nbsp;&nbsp;&nbsp;
  361. <%=L_MAX_CONNECTIONSTEXT%>
  362. </TD>
  363. <TD>
  364. <INPUT name=txtMaxCon size=10 class="formField" tabIndex=4 value="<%=F_FTPMaxCon%>" OnKeyUP="javaScript:checkUserLimit(this,'conftp');" OnKeypress="javaScript:checkKeyforNumbers(this);" onblur = "checkforEmptyMaxCon();">
  365. </TD>
  366. </TR>
  367. <TR>
  368. <TD>
  369. &nbsp;
  370. </TD>
  371. </TR>
  372. <TR>
  373. <TD>
  374. &nbsp;&nbsp;&nbsp;
  375. <%=L_CON_TIMEOUT%>
  376. </TD>
  377. <TD>
  378. <INPUT name=txtConTimeOut size=10 class="formField" tabIndex=5 value="<%=F_FTPCon_Timeout%>" OnKeyUP="javaScript:checkUserLimit(this,'contimeout');" OnKeypress="javaScript:checkKeyforNumbers(this);" onblur = "checkforEmptyConTimeOut()">
  379. </TD>
  380. </TR>
  381. </TABLE>
  382. <input type=hidden name=hdnFTPMaxCon value = "<%=F_FTPMaxCon%>" >
  383. <input type=hidden name=hdnFTPConTimeout value = "<%=F_FTPCon_Timeout%>" >
  384. <input type=hidden name=hdnFTPListStyle value = "<%=F_selectDirListStyle%>" >
  385. <input type=hidden name=hdnFTPEnabled>
  386. <%
  387. End Function
  388. '-------------------------------------------------------------------------
  389. 'Function name: ServeVariablesFromForm()
  390. 'Description: Serves in getting the data from Client
  391. 'Input Variables: None
  392. 'Output Variables: None
  393. 'Returns: True/False
  394. 'Global Variables: None
  395. '-------------------------------------------------------------------------
  396. Function ServeVariablesFromForm
  397. 'setting the form variables
  398. F_selectDirListStyle = Request.Form("hdnFTPListStyle")
  399. F_FTPMaxCon = Request.Form("hdnFTPMaxCon")
  400. F_FTPCon_Timeout = Request.Form("hdnFTPConTimeout")
  401. F_FTPEnabled = Request.Form("hdnFTPEnabled")
  402. 'set the FTP master settings
  403. If ConfigWebServer()then
  404. ServeVariablesFromForm = true
  405. else
  406. ServeVariablesFromForm = false
  407. end if
  408. End Function
  409. '-------------------------------------------------------------------------
  410. 'Function name: InitObjects
  411. 'Description: Initialization of global variables is done
  412. 'Input Variables: None
  413. 'Returns: true/false
  414. 'Global Variables: G_objService
  415. ' G_objSites
  416. '--------------------------------------------------------------------------
  417. Function InitObjects()
  418. Err.Clear
  419. on error resume next
  420. ' Get instances of IIS_FTPServiceSetting that are visible throughout
  421. Set G_objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  422. set G_objSites = G_objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPServiceSetting"))
  423. if Err.number <> 0 or G_objSites.count = 0 then
  424. FTPInstalled = false
  425. Err.Clear
  426. else
  427. FTPInstalled = true
  428. end if
  429. end function
  430. '-------------------------------------------------------------------------
  431. 'Function name: ConfigWebServer
  432. 'Description: Sets Master Settings
  433. 'Input Variables: None
  434. 'Returns: true/false
  435. 'Global Variables: G_objService
  436. ' G_objSites
  437. '--------------------------------------------------------------------------
  438. Function ConfigWebServer()
  439. Err.Clear
  440. on error resume next
  441. ConfigWebServer = false
  442. 'init global var FTPInstalled
  443. InitObjects()
  444. '
  445. ' First, set the proper state for FTP service
  446. '
  447. ' If user select to enable FTP service
  448. if F_FTPEnabled = "true" Then
  449. 'If FTP Service is not started, we need to start it
  450. 'and set it state to automatic
  451. If Not IsFTPEnabled Then
  452. Call EnableFTP()
  453. End If
  454. if Not IsAdminFTPServerExistAndRunning() Then
  455. If IsAdminFTPServerExist() Then
  456. 'Stop the running FTP server
  457. If Not StopDefaultFTPServer() Then
  458. SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  459. Exit Function
  460. End If
  461. If Not StartAdminFTPServer() Then
  462. SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  463. Exit Function
  464. End If
  465. Else
  466. 'If admin FTP server does not exist, create and start it
  467. 'when create it, it will start be default.
  468. If Not CreateAdminFTPServer() Then
  469. SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  470. Exit Function
  471. End If
  472. 'Stop the running FTP server
  473. If Not StopDefaultFTPServer() Then
  474. SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  475. Exit Function
  476. End If
  477. If Not StartAdminFTPServer() Then
  478. SetErrMsg L_CREATEADMINFTPSERVER_ERRORMESSAGE
  479. Exit Function
  480. End If
  481. End If
  482. End If
  483. elseif F_FTPEnabled = "false" Then
  484. 'If admin FTP server is running, stop it. Otherwise, do nothing.
  485. if IsAdminFTPServerExistAndRunning() Then
  486. if StopAdminFTPServer() Then
  487. ConfigWebServer = true
  488. Else
  489. SA_TraceOut "Ftp_MasterSettings", "Failed to stop admin FTP Server"
  490. End If
  491. End If
  492. else
  493. Call SA_TraceOut("Ftp_MasterSettings.asp", "ConfigWebServer(): Unexpected Error")
  494. End If
  495. 'Set the FTP mastersettings
  496. if FTPInstalled = true then
  497. if NOT SetMasterSiteSettings() then
  498. ServeFailurePage L_UNABLE_TO_SETMASTERSETTINGS ,sReturnURL
  499. exit function
  500. end if
  501. end if
  502. 'Release the objects
  503. set G_objSites = nothing
  504. set G_objService = nothing
  505. ConfigWebServer = true
  506. end function
  507. '-------------------------------------------------------------------------
  508. 'Function name: ValidateInputs
  509. 'Description: Validates the inputs
  510. 'Input Variables: None
  511. 'Returns: true/false
  512. 'Global Variables: None
  513. '--------------------------------------------------------------------------
  514. Function ValidateInputs()
  515. Err.Clear
  516. on error resume next
  517. Dim objFso,nRetVal
  518. ValidateInputs = false
  519. ' Check whether directory exists
  520. ' If directory does not exist, create the web site if the drive letter is valid
  521. ' else give error message
  522. Set objFso = server.CreateObject("Scripting.FileSystemObject")
  523. if Err.number <> 0 then
  524. SetErrMsg L_FILEINFORMATION_ERRORMESSAGE
  525. exit function
  526. end if
  527. 'nRetVal = CreateSitePath( objFso, F_FTPRootDir )
  528. if nRetVal <> CONST_SUCCESS then
  529. if nRetVal = CONST_INVALID_DRIVE then
  530. SetErrMsg L_INVALID_DRIVE_ERRORMESSAGE
  531. elseif nRetVal = CONST_NOTNTFS_DRIVE then
  532. SetErrMsg L_NOT_NTFS_DRIVE_ERRORMESSAGE
  533. else
  534. SetErrMsg L_FAILED_CREATE_DIR_ERRORMESSAGE
  535. end if
  536. exit Function
  537. end if
  538. 'release the object
  539. set objFso = nothing
  540. ValidateInputs = true
  541. End Function
  542. '-------------------------------------------------------------------------
  543. 'Function name: SetMasterSiteSettings
  544. 'Description: sets the FTP master settings
  545. 'Input Variables: None
  546. 'Returns: true/false
  547. 'Global Variables: None
  548. '--------------------------------------------------------------------------
  549. Function SetMasterSiteSettings()
  550. Err.Clear
  551. on error resume next
  552. Dim instSite
  553. Dim objService
  554. Dim objSites
  555. SetMasterSiteSettings = false
  556. Set objService = getWMIConnection(CONST_WMI_IIS_NAMESPACE)
  557. set objSites = objService.InstancesOf(GetIISWMIProviderClassName("IIS_FTPServiceSetting"))
  558. if Err.number <> 0 or objSites.count = 0 then
  559. exit function
  560. end if
  561. for each instSite in objSites
  562. if instSite.Name = "MSFTPSVC" then
  563. 'instSite.AllowAnonymous = F_FTPAllowAnonymous
  564. if F_selectDirListStyle = "UNIX" then
  565. instSite.MSDosDirOutput = false
  566. else
  567. instSite.MSDosDirOutput = true
  568. end if
  569. 'set max connections
  570. if trim(F_FTPMaxCon) = "" then
  571. instSite.MaxConnections = 100000
  572. else
  573. instSite.MaxConnections = clng(F_FTPMaxCon)
  574. end if
  575. 'set connection timeout
  576. if trim(F_FTPCon_Timeout) = "" then
  577. instSite.ConnectionTimeout = 900
  578. else
  579. instSite.ConnectionTimeout = clng(F_FTPCon_Timeout)
  580. end if
  581. instSite.Put_(WBEMFLAG)
  582. if err.number <> 0 then
  583. SA_TraceOut "FTP_Master Settings", "Unable to set the FTP Master Settings"
  584. exit function
  585. end if
  586. SetMasterSiteSettings = true
  587. exit for
  588. end if
  589. next
  590. 'Release the objects
  591. set objSites = nothing
  592. set objService = nothing
  593. SetMasterSiteSettings = true
  594. End Function
  595. '-------------------------------------------------------------------------
  596. 'Function name: SetWebSiteRootVal
  597. 'Description: sets the FTP site root dir to the registry key
  598. 'Input Variables: strWebRootDir
  599. 'Returns: true/false
  600. 'Global Variables: None
  601. '--------------------------------------------------------------------------
  602. Function SetWebSiteRootVal(strWebRootDir)
  603. Err.Clear
  604. on error resume next
  605. Dim IRC, objGetHandle, rtnCreateKey
  606. SetWebSiteRootVal = FALSE
  607. set objGetHandle = RegConnection()
  608. rtnCreateKey = RegCreateKey(objGetHandle,CONST_WEBBLADES_REGKEY)
  609. If Err.number <> 0 then
  610. SetErrMsg L_UNABLETOCREATE_KEY_ERRORMESSAGE
  611. exit function
  612. end if
  613. IRC = objGetHandle.SetStringValue(G_HKEY_LOCAL_MACHINE,CONST_WEBBLADES_REGKEY,CONST_FTPSITEROOT_REGVAL,strWebRootDir)
  614. If Err.number <> 0 then
  615. SetErrMsg L_SET_WEBROOT_VAL_FAILED_ERRORMESSAGE
  616. exit function
  617. end if
  618. 'release the object
  619. set objGetHandle = nothing
  620. SetWebSiteRootVal = TRUE
  621. End Function
  622. '-------------------------------------------------------------------------
  623. 'Function name: SetVariablesFromSystem
  624. 'Description: Serves in Getting the data from Client
  625. 'Input Variables: None
  626. 'Output Variables: None
  627. 'Returns: None
  628. 'Global Variables: G_objSites
  629. '-------------------------------------------------------------------------
  630. Function SetVariablesFromSystem
  631. Err.Clear
  632. on Error resume next
  633. Dim nRetval
  634. Dim instSite
  635. for each instSite in G_objSites
  636. if instSite.Name = "MSFTPSVC" then
  637. if instSite.MSDosDirOutput = false then 'get Directory listing style
  638. F_selectDirListStyle = "UNIX"
  639. else
  640. F_selectDirListStyle = "MS-DOS"
  641. end if
  642. F_FTPMaxCon = instSite.MaxConnections 'get max connection value
  643. F_FTPCon_Timeout = instSite.ConnectionTimeout 'get connection timeout value
  644. exit for
  645. end if
  646. next
  647. End Function
  648. %>