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.

308 lines
11 KiB

  1. <% '-------------------------------------------------------------------------
  2. ' share_ftpnew.asp: Serves in creating new FTP share properties.
  3. '
  4. ' Copyright (c) Microsoft Corporation. All rights reserved.
  5. '
  6. ' Date Description
  7. ' 9 Mar 2001 Creation Date.
  8. ' 17 Mar 2001 Modified Date
  9. '-------------------------------------------------------------------------
  10. '-------------------------------------------------------------------------
  11. 'Global Variables & Constants
  12. '-------------------------------------------------------------------------
  13. Const CONST_ACCESS_READ_ONLY = 1 ' wmi access flag for Read Only
  14. Const CONST_ACCESS_WRITE_ONLY = 2 ' wmi access flag for Write only
  15. Const CONST_CHECKBOX_SELECTED = "CHECKED" ' status for checkbox-CHECKED
  16. Const CONST_CHECKBOX_NOT_SELECTED = "" ' status for checkbox-NOT CHECKED
  17. 'FTP WMI Path
  18. Const CONST_FTPWMIPATH = "MSFTPSVC/1/ROOT/"
  19. '-------------------------------------------------------------------------
  20. 'Form Variables
  21. '-------------------------------------------------------------------------
  22. Dim F_strReadCheckStatus_FtpNew ' to set the Read CheckBox status
  23. Dim F_strWriteCheckStatus_FtpNew ' to set the Write CheckBox status
  24. Dim F_strLogVisitsCheckStatus_FtpNew ' to set the LogVisits CheckBox status
  25. Dim F_nAccessReadWrite_FtpNew ' to store the access value(0,1,2 or 3)
  26. Dim F_nLogVisits_FtpNew ' to store the log visit status(0 or 1)
  27. %>
  28. <SCRIPT language="JavaScript" >
  29. // Set the initial form values
  30. function FTPInit()
  31. {
  32. // no initializations required for the checkboxes
  33. // the status of checkBoxes is taken care on server side
  34. }// end of function Init()
  35. // Validate the form values in the page
  36. function FTPValidatePage()
  37. {
  38. // set the hidden variables. No other validations required here
  39. UpdateHiddenVariablesFTPNew();
  40. return true;
  41. }
  42. // Function to set the hidden varibales to be sent to the server
  43. function FTPSetData()
  44. {
  45. // "OK" is clicked. The values are already set
  46. // in the FTPValidatePage function above. Nothing to set here.
  47. }
  48. // Function to update the hidden values in the form
  49. function UpdateHiddenVariablesFTPNew()
  50. {
  51. var objForm
  52. // initialize the access value to 0 (NO Read, NO Write access)
  53. var accessValue = 0
  54. // assign the form object to variable
  55. objForm = eval("document.frmTask")
  56. // if the allow read is checked, make access value as 1
  57. // for read only - access = 1 (Read Only, NO Write)
  58. if (objForm.chkAllowReadFtpNew.checked)
  59. {
  60. accessValue = accessValue + 1;
  61. }
  62. // if the allow write is checked, make access value as 2 or 3
  63. // for read and write - access = 3 (Read AND Write)
  64. // for write only - access = 2 (NO Read, Write Only)
  65. if (objForm.chkAllowWriteFtpNew.checked)
  66. {
  67. accessValue = accessValue + 2;
  68. }
  69. // now update the hidden form value with the access value
  70. objForm.hdnintAccessReadWriteFtpNew.value = accessValue;
  71. // update the hidden value for "Log Visits" checkBox
  72. // value = 0 if checkBox NOT CHECKED ; value = 1 if CHECKED
  73. objForm.hdnintLogVisitsFtpNew.value = 0;
  74. if (objForm.chkLogVisitsFtpNew.checked)
  75. {
  76. objForm.hdnintLogVisitsFtpNew.value = 1;
  77. }
  78. } // end of UpdateHiddenVariables()
  79. </SCRIPT>
  80. <% '-------------------------------------------------------------------------
  81. ' Function name: ServeFTPPage
  82. ' Description: Serves in displaying the page content
  83. ' Input Variables: None
  84. ' Output Variables: None
  85. ' Returns: None
  86. ' Global Variables: In: L_* - Localization content(form label text)
  87. ' In: F_strReadCheckStatus_FtpNew - to set status of Read CheckBox
  88. ' In: F_strWriteCheckStatus_FtpNew - to set status of Write CheckBox
  89. ' In: F_strLogVisitsCheckStatus_FtpNew - to set status of LogVisits CheckBox
  90. '-------------------------------------------------------------------------
  91. Function ServeFTPPage
  92. On Error Resume Next
  93. Err.Clear
  94. %>
  95. <table valign="middle" align="left" border="0" cellspacing="0" cellpadding="2">
  96. <tr>
  97. <td class="TasksBody">
  98. <%=L_ALLOW_PERMISSIONS_LABEL_TEXT%>
  99. </td>
  100. </tr>
  101. <tr>
  102. <td class="TasksBody" align="left">
  103. <input name="chkAllowReadFtpNew" class="FormCheckBox" type="checkbox" <%=F_strReadCheckStatus_FtpNew%> >
  104. <%=L_READ_LABEL_TEXT%>
  105. </td>
  106. </tr>
  107. <tr>
  108. <td class="TasksBody" align="left">
  109. <input name="chkAllowWriteFtpNew" class="FormCheckBox" type="checkbox" <%=F_strWriteCheckStatus_FtpNew%> >
  110. <%=L_WRITE_LABEL_TEXT%>
  111. </td>
  112. </tr>
  113. <tr>
  114. <td class="TasksBody" align="left">
  115. <%=L_LOGVISITS_LABEL_TEXT%>
  116. <input name="chkLogVisitsFtpNew" class="FormCheckBox" type="checkbox" <%=F_strLogVisitsCheckStatus_FtpNew%> >
  117. </td>
  118. </tr>
  119. </table>
  120. <% Call ServeFTPHiddenValues
  121. End Function
  122. '-------------------------------------------------------------------------
  123. ' SubRoutine: FTPOnPostBackPage
  124. ' Description: Serves in getting the values from the form.
  125. ' Input Variables: None
  126. ' Output Variables: None
  127. ' Returns: None
  128. ' Global Variables:
  129. ' Out: F_nAccessReadWrite_FtpNew - the access permissions
  130. ' (0,1,2 or 3 only)
  131. ' Out: F_nLogVisits_FtpNew - do we log the visits ?
  132. ' (0 or 1 only)
  133. ' Out: F_strReadCheckStatus_FtpNew - status of READ checkBox
  134. ' Out: F_strWriteCheckStatus_FtpNew - status of WRITE checkBox
  135. ' Out: F_strLogVisitsCheckStatus_FtpNew - status of LOGVISITS chkBox
  136. '-------------------------------------------------------------------------
  137. Sub FTPOnPostBackPage
  138. Err.Clear
  139. On Error Resume Next
  140. ' get the values of the hidden variables from the form
  141. F_nAccessReadWrite_FtpNew = Request.Form("hdnintAccessReadWriteFtpNew")
  142. F_nLogVisits_FtpNew = Request.Form("hdnintLogVisitsFtpNew")
  143. ' initialize the status of CheckBoxes to "NOT CHECKED"
  144. F_strReadCheckStatus_FtpNew = CONST_CHECKBOX_NOT_SELECTED
  145. F_strWriteCheckStatus_FtpNew = CONST_CHECKBOX_NOT_SELECTED
  146. F_strLogVisitsCheckStatus_FtpNew = CONST_CHECKBOX_NOT_SELECTED
  147. ' convert to integer type
  148. F_nAccessReadWrite_FtpNew = CInt(F_nAccessReadWrite_FtpNew)
  149. F_nLogVisits_FtpNew = CInt(F_nLogVisits_FtpNew)
  150. ' set the status of "CheckBoxes" if the values are set
  151. '
  152. ' if the Read access is given.
  153. ' perform an AND to verify if the value is set
  154. If (F_nAccessReadWrite_FtpNew AND CONST_ACCESS_READ_ONLY) Then
  155. F_strReadCheckStatus_FtpNew = CONST_CHECKBOX_SELECTED
  156. End If
  157. ' if the write access is given.
  158. ' perform an AND to verify if the value is set
  159. If (F_nAccessReadWrite_FtpNew AND CONST_ACCESS_WRITE_ONLY) Then
  160. F_strWriteCheckStatus_FtpNew = CONST_CHECKBOX_SELECTED
  161. End If
  162. ' if the "Log Visits" is checked.
  163. ' the 0 OR 1 is converted to Boolean and verified instead of comparision
  164. If CBool(F_nLogVisits_FtpNew) Then
  165. F_strLogVisitsCheckStatus_FtpNew = CONST_CHECKBOX_SELECTED
  166. End If
  167. End Sub
  168. '-------------------------------------------------------------------------
  169. ' Subroutine: FTPOnInitPage
  170. ' Description: Serves in getting values from system (default values)
  171. ' Input Variables: None
  172. ' Output Variables: None
  173. ' Returns: None
  174. ' Global Variables: Out: F_nAccessReadWrite_FtpNew - the access permissions
  175. ' (0,1,2 or 3 only)
  176. ' Out: F_nLogVisits_FtpNew - do we log the visits ?
  177. ' (0 or 1 only)
  178. ' Out: F_strReadCheckStatus_FtpNew - status of READ checkBox
  179. ' Out: F_strWriteCheckStatus_FtpNew - status of WRITE checkBox
  180. ' Out: F_strLogVisitsCheckStatus_FtpNew - status of LOGVISITS chkBox
  181. '-------------------------------------------------------------------------
  182. Sub FTPOnInitPage
  183. Err.Clear
  184. On Error Resume Next
  185. ' initialize the checkbox status
  186. ' set the Allow read , NO Write by default
  187. F_nAccessReadWrite_FtpNew = 1
  188. F_strReadCheckStatus_FtpNew = CONST_CHECKBOX_SELECTED
  189. F_strWriteCheckStatus_FtpNew = CONST_CHECKBOX_NOT_SELECTED
  190. ' set the Log Visits to True (checked)
  191. F_nLogVisits_FtpNew = 1
  192. F_strLogVisitsCheckStatus_FtpNew = CONST_CHECKBOX_SELECTED
  193. End Sub
  194. '-------------------------------------------------------------------------
  195. ' Function name: SetFTPshareProp
  196. ' Description: Serves in setting the values of the ftp share
  197. ' Input Variables: None
  198. ' Output Variables: None
  199. ' Returns: TRUE if successful, else FALSE
  200. ' Global Variables:
  201. ' In: L_* - Localization content(error messages)
  202. ' In: F_nAccessReadWrite_FtpNew - the access permissions
  203. ' (0,1,2 or 3 only)
  204. ' In: F_nLogVisits_FtpNew - do we log the visits ?
  205. ' (0 or 1 only)
  206. ' Support functions used: getFTPShareObject() - to get the share object
  207. '-------------------------------------------------------------------------
  208. Function SetFTPshareProp
  209. Err.Clear
  210. On Error Resume Next
  211. Dim objFTPShare ' to get the share object for which we need to
  212. ' change properties
  213. ' get the FTP share object for which we need to set properties
  214. Set objFTPShare = getFTPShareObject()
  215. '
  216. ' It is enough to set the boolean values(AccessRead and AccessWrite).
  217. ' The AccessFlags(integer) need not be set.(wmi takes care of it)
  218. ' if the Read CheckBox is checked, set the flag to TRUE, else FALSE
  219. If (F_nAccessReadWrite_FtpNew AND CONST_ACCESS_READ_ONLY) Then
  220. objFTPShare.AccessRead = True
  221. Else
  222. objFTPShare.AccessRead = False
  223. End If
  224. ' if the Write CheckBox is checked, set the flag to TRUE, else FALSE
  225. If (F_nAccessReadWrite_FtpNew AND CONST_ACCESS_WRITE_ONLY) Then
  226. objFTPShare.AccessWrite = True
  227. Else
  228. objFTPShare.AccessWrite = False
  229. End If
  230. ' bring the changes made to properties to effect
  231. objFTPShare.Put_
  232. If Err.Number <> 0 Then
  233. ' the changes could not be PUT (system values could not be changed)
  234. SA_SetErrMsg L_FAILEDTOSETSHAREINFO_ERRORMESSAGE
  235. Set objFTPShare = Nothing
  236. Exit Function
  237. End If
  238. ' clean up
  239. Set objFTPShare = Nothing
  240. 'Function call to set the Dont log property
  241. If SetDontLogProp(F_StrShareName, F_nLogVisits_FtpNew) Then
  242. SA_SetErrMsg L_LOG_VISITS_ERRORMESSAGE
  243. SetFTPshareProp = False
  244. Exit Function
  245. End If
  246. SetFTPshareProp = True
  247. End Function
  248. '-------------------------------------------------------------------------
  249. ' SubRoutine: ServeFTPHiddenValues
  250. ' Description: Serves in printing the hidden values of the form
  251. ' Input Variables: None
  252. ' Output Variables: None
  253. ' Returns: None
  254. ' Global Variables:
  255. ' In: F_nAccessReadWrite_FtpNew - the access permissions
  256. ' In: F_nLogVisits_FtpNew - do we log the visits ?
  257. ' (0 or 1 only)
  258. '-------------------------------------------------------------------------
  259. Sub ServeFTPHiddenValues
  260. ' the hidden values to store the access flag value
  261. ' and the "Log Visits" value
  262. ' (Whether the checkBox must be checked OR NOT)
  263. %>
  264. <input type="hidden" name ="hdnintAccessReadWriteFtpNew" value="<%=F_nAccessReadWrite_FtpNew%>" >
  265. <input type="hidden" name ="hdnintLogVisitsFtpNew" value="<%=F_nLogVisits_FtpNew%>" >
  266. <%
  267. End Sub
  268. %>