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.

358 lines
13 KiB

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