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.

305 lines
11 KiB

  1. <%
  2. '-------------------------------------------------------------------------
  3. ' share_httpprop.asp: Serves in modifying HTTP share properties.
  4. '
  5. ' Copyright (c) Microsoft Corporation. All rights reserved.
  6. '
  7. ' Date Description
  8. ' 12 March 2001 Creation Date.
  9. '-------------------------------------------------------------------------
  10. '-------------------------------------------------------------------------
  11. 'Form Variables
  12. '-------------------------------------------------------------------------
  13. Dim F_strReadCheckStatus_HttpProp ' to set the Read CheckBox status
  14. Dim F_strWriteCheckStatus_HttpProp ' to set the Write CheckBox status
  15. Dim F_intAccessReadWrite_HttpProp ' to store the access value(0,1,2 or 3)
  16. Const CONST_READ_PERMISSION=1
  17. 'constants used for querying WMI for Http share
  18. Const CONST_IIS = "IIS://"
  19. Const CONST_ROOT = "/Root/"
  20. F_intAccessReadWrite_HttpProp=CONST_READ_PERMISSION ' allow read permission
  21. '-------------------------------------------------------------------------
  22. 'Global Variables
  23. '-------------------------------------------------------------------------
  24. ' the required constants are already declared in the Share_FtpProp.asp
  25. %>
  26. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js"></script>
  27. <script language="JavaScript" >
  28. // Set the initial form values
  29. function HTTPInit()
  30. {
  31. // no initializations required for the checkboxes
  32. // the status of checkBoxes is taken care on server side
  33. }// end of function Init()
  34. // Validate the page form values
  35. function HTTPValidatePage()
  36. {
  37. // the LeftSide tabs are clicked, "OK" is not clicked
  38. // set the hidden variables. No other validations required here
  39. UpdateHiddenVariablesHttpProp();
  40. return true;
  41. }
  42. // Function to set the hidden varibales to be sent to the server
  43. function HTTPSetData()
  44. {
  45. // "OK" is clicked. The hidden values are already set in the
  46. // HTTPValidatePage function above. Nothing to set here.
  47. }
  48. // Function to update the hidden values in the form
  49. function UpdateHiddenVariablesHttpProp()
  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.chkAllowReadHttpProp.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.chkAllowWriteHttpProp.checked)
  66. {
  67. accessValue = accessValue + 2;
  68. }
  69. // now update the hidden form value with the access value
  70. objForm.hdnintAccessReadWriteHttpProp.value = accessValue;
  71. } // end of UpdateHiddenVariablesHttpProp()
  72. </script>
  73. <%
  74. '-------------------------------------------------------------------------
  75. ' Function name: ServeHTTPPage
  76. ' Description: Serves in displaying the page content
  77. ' Input Variables: None
  78. ' Output Variables: None
  79. ' Returns: None
  80. ' Global Variables:
  81. ' In: L_* - Localization content(form label text)
  82. ' In: F_strReadCheckStatus_HttpProp - status of Read CheckBox
  83. ' In: F_strWriteCheckStatus_HttpProp - status of Write CheckBox
  84. '-------------------------------------------------------------------------
  85. Function ServeHTTPPage
  86. Err.Clear
  87. On Error Resume Next
  88. %>
  89. <table border="0" cellspacing="0" cellpadding="0">
  90. <tr>
  91. <td class="TasksBody">
  92. <%=L_ALLOW_PERMISSIONS_LABEL_TEXT%>
  93. </td>
  94. </tr>
  95. <tr>
  96. <td align="left" class="TasksBody">
  97. <input name="chkAllowReadHttpProp" class="FormCheckBox" type="checkbox" <%=F_strReadCheckStatus_HttpProp%> >
  98. <%=L_READ_LABEL_TEXT%>
  99. </td>
  100. </tr>
  101. <tr>
  102. <td align="left" class="TasksBody">
  103. <input name="chkAllowWriteHttpProp" class="FormCheckBox" type="checkbox" <%=F_strWriteCheckStatus_HttpProp%> >
  104. <%=L_WRITE_LABEL_TEXT%>
  105. </td>
  106. </tr>
  107. </table>
  108. <%
  109. Call ServeHTTPHiddenValues
  110. End Function
  111. '-------------------------------------------------------------------------
  112. ' Function name: HTTPOnPostBackPage
  113. ' Description: Serves in getting the values from the form.
  114. ' Input Variables: None
  115. ' Output Variables: None
  116. ' Returns: None
  117. ' Global Variables:
  118. ' Out: F_intAccessReadWrite_HttpProp - the access permissions
  119. ' (0,1,2 or 3 only)
  120. ' Out: F_strReadCheckStatus_HttpProp - status of READ checkBox
  121. ' Out: F_strWriteCheckStatus_HttpProp - status of WRITE checkBox
  122. '
  123. ' Status of checkBoxes = "CHECKED" or ""
  124. '-------------------------------------------------------------------------
  125. Function HTTPOnPostBackPage
  126. Err.Clear
  127. On Error Resume Next
  128. ' get the value of the hidden variable from the form
  129. F_intAccessReadWrite_HttpProp = Request.Form("hdnintAccessReadWriteHttpProp")
  130. ' If the share is not HTTP and the checkBox is checked now,
  131. ' give the default values for the new http share
  132. If NOT IsNumeric(F_intAccessReadWrite_HttpProp) Then
  133. F_intAccessReadWrite_HttpProp = CONST_READ_PERMISSION ' read only permission
  134. End If
  135. ' initialize the status of CheckBoxes to "NOT CHECKED"
  136. F_strReadCheckStatus_HttpProp = CONST_CHECKBOX_NOT_SELECTED
  137. F_strWriteCheckStatus_HttpProp = CONST_CHECKBOX_NOT_SELECTED
  138. ' convert to integer type
  139. F_intAccessReadWrite_HttpProp = CInt(F_intAccessReadWrite_HttpProp)
  140. '
  141. ' set the status of "CheckBoxes" if the values are set
  142. '
  143. ' if the Read access is given.
  144. ' perform an AND to verify if the value is set
  145. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_READ_ONLY) Then
  146. F_strReadCheckStatus_HttpProp = CONST_CHECKBOX_SELECTED
  147. End If
  148. ' if the write access is given.
  149. ' perform an AND to verify if the value is set
  150. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_WRITE_ONLY) Then
  151. F_strWriteCheckStatus_HttpProp = CONST_CHECKBOX_SELECTED
  152. End If
  153. End Function
  154. '-------------------------------------------------------------------------
  155. ' Function name: HTTPOnInitPage
  156. ' Description: Serves in getting the values from system
  157. ' Input Variables: None
  158. ' Output Variables: None
  159. ' Returns: None
  160. ' Global Variables:
  161. ' Out: F_intAccessReadWrite_HttpProp - the access permissions
  162. ' Out: F_strReadCheckStatus_HttpProp - status of READ checkBox
  163. ' Out: F_strWriteCheckStatus_HttpProp - status of WRITE checkBox
  164. '
  165. 'Status of checkBoxes = "CHECKED" or ""
  166. 'Support functions used: getHTTPShareObject() - to get the share object
  167. '-------------------------------------------------------------------------
  168. Function HTTPOnInitPage
  169. Err.Clear
  170. On Error Resume Next
  171. Dim objHTTPShare ' to get the share object for which we need to
  172. ' get the properties from
  173. ' initialize the checkbox status for all checkboxes as "not checked"
  174. F_strReadCheckStatus_HttpProp = CONST_CHECKBOX_NOT_SELECTED
  175. F_strWriteCheckStatus_HttpProp = CONST_CHECKBOX_NOT_SELECTED
  176. ' get the http share object from which we will get the properties
  177. Set objHTTPShare = getHTTPShareObject()
  178. ' get the access flags of the share
  179. F_intAccessReadWrite_HttpProp = CInt(objHTTPShare.AccessFlags)
  180. ' if read flag is set, the Read checkBox must be checked
  181. ' perform an AND to verify if the value is set
  182. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_READ_ONLY) Then
  183. F_strReadCheckStatus_HttpProp = CONST_CHECKBOX_SELECTED
  184. End If
  185. ' if write flag is set, the Write checkBox must be checked
  186. ' perform an AND to verify if the value is set
  187. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_WRITE_ONLY) Then
  188. F_strWriteCheckStatus_HttpProp = CONST_CHECKBOX_SELECTED
  189. End If
  190. ' clean up
  191. Set objHTTPShare = Nothing
  192. End Function
  193. '-------------------------------------------------------------------------
  194. ' Function name: SetHTTPshareProp
  195. ' Description: Serves in setting the values of the http share
  196. ' Input Variables: None
  197. ' Output Variables: None
  198. ' Returns: TRUE if successful, else FALSE
  199. ' Global Variables:
  200. ' In: L_* - Localization content(error messages)
  201. ' In: F_intAccessReadWrite_HttpProp - the access permissions
  202. ' (0,1,2 or 3 only)
  203. '
  204. ' Support functions used: getHTTPShareObject() - to get the share object
  205. '-------------------------------------------------------------------------
  206. Function SetHTTPshareProp
  207. On Error Resume Next
  208. Err.Clear
  209. Dim objHTTPShare ' to get the share object for which we need to change properties
  210. Const CONST_ACCESSREAD="AccessRead"
  211. Const CONST_ACCESSWRITE="AccessWrite"
  212. ' get the HTTP share object for which we need to set properties
  213. Set objHTTPShare = getHTTPShareObject()
  214. ' It is enough to set the boolean values(AccessRead and AccessWrite).
  215. ' The AccessFlags(integer) need not be set.(wmi takes care of it)
  216. ' if the Read CheckBox is checked, set the flag to TRUE, else FALSE
  217. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_READ_ONLY) Then
  218. objHTTPShare.Put CONST_ACCESSREAD,True
  219. Else
  220. objHTTPShare.Put CONST_ACCESSREAD,False
  221. End If
  222. ' if the Write CheckBox is checked, set the flag to TRUE, else FALSE
  223. If (F_intAccessReadWrite_HttpProp AND CONST_ACCESS_WRITE_ONLY) Then
  224. objHTTPShare.Put CONST_ACCESSWRITE,True
  225. Else
  226. objHTTPShare.Put CONST_ACCESSWRITE,False
  227. End If
  228. ' bring the changes made to properties to effect
  229. objHTTPShare.SetInfo()
  230. ' clean up
  231. Set objHTTPShare = Nothing
  232. ' in case of any error, return FALSE, else return TRUE
  233. If Err.number <> 0 Then
  234. ' the changes could not be PUT (system values could not be changed)
  235. SA_SetErrMsg L_FAILEDTOSETSHAREINFO_ERRORMESSAGE & " (" & Hex(Err.number) & ") "
  236. SetHTTPshareProp = False
  237. Exit Function
  238. Else
  239. SetHTTPshareProp = True
  240. End If
  241. End Function
  242. '-------------------------------------------------------------------------
  243. ' Function name: ServeHTTPHiddenValues
  244. ' Description: Serves in printing the hidden values of the form
  245. ' Input Variables: None
  246. ' Output Variables: None
  247. ' Returns: None
  248. ' Global Variables:
  249. ' In: F_intAccessReadWrite_HttpProp - the access permissions
  250. '-------------------------------------------------------------------------
  251. Function ServeHTTPHiddenValues
  252. ' the hidden values to store the access flag value
  253. ' (Whether the checkBoxes must be checked OR NOT)
  254. %>
  255. <input type="hidden" name="hdnintAccessReadWriteHttpProp" value="<%=F_intAccessReadWrite_HttpProp%>" >
  256. <%
  257. End Function
  258. %>