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.

787 lines
29 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' quota_quota.asp: manage default quotas on the volume
  6. '
  7. ' Copyright (c) Microsoft Corporation. All rights reserved.
  8. '
  9. ' Date Description
  10. ' 17-Jan-01 Creation date
  11. ' 15-Mar-01 Ported to 2.0
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual = "/admin/inc_framework.asp" -->
  15. <!-- #include file="loc_quotas.asp" -->
  16. <!-- #include file="inc_quotas.asp" -->
  17. <%
  18. '-------------------------------------------------------------------------
  19. ' Global Variables
  20. '-------------------------------------------------------------------------
  21. Dim G_nRadioChecked ' to set radioButton values - contains 1 or 2 only
  22. Dim SOURCE_FILE ' the source file name used while Tracing
  23. SOURCE_FILE = SA_GetScriptFileName()
  24. '-------------------------------------------------------------------------
  25. ' Global Constants
  26. '-------------------------------------------------------------------------
  27. Const CONST_ENABLE_QUOTA_MGMT = 1 ' Enable quota management
  28. Const CONST_DISABLE_QUOTA_MGMT = 0 ' Disable quota management
  29. Const CONST_ENFORCE_QUOTA_LIMIT = 2 ' Deny DiskSpace if user exceeds limit
  30. '-------------------------------------------------------------------------
  31. ' Global Form Variables
  32. '-------------------------------------------------------------------------
  33. Dim F_strVolName ' Volume Name
  34. Dim F_nChkEnableQuotaMgmt ' set disk management state checkBox
  35. Dim F_blnChkDenyDiskSpace ' Enable deny disk space checkBox
  36. Dim F_blnChkEnableLogEventExceedQuotaLimit ' Log if user exceeds quota limit checkBox
  37. Dim F_blnChkEnableLogEventExceedWarningLimit ' Log if user exceeds warning limit checkBox
  38. Dim F_LimitSize ' Disk limit size - textBox value
  39. Dim F_LimitUnits ' Disk limit size units - comboBox value
  40. Dim F_ThresholdSize ' Warning level set for the user - textBox value
  41. Dim F_ThresholdUnits ' WarningLimit Uunits for the warning level set - comboBox Value
  42. '======================================================
  43. ' Entry point
  44. '======================================================
  45. Dim page
  46. DIM L_PAGETITLE_QUOTA_QUOTA_TEXT
  47. ' get the volumename to append to title
  48. Call getVolumeName()
  49. ' append the volume name to the title
  50. Dim arrVarReplacementStrings(2)
  51. arrVarReplacementStrings(0) = getVolumeLabelForDrive(F_strVolName)
  52. arrVarReplacementStrings(1) = F_strVolName
  53. ' append the volume name to the title
  54. L_PAGETITLE_QUOTA_QUOTA_TEXT = SA_GetLocString("diskmsg.dll", "403E0047", arrVarReplacementStrings)
  55. Dim aPageTitle(2)
  56. aPageTitle(0) = L_BROWSERCAPTION_DEFAULTQUOTA_TEXT
  57. aPageTitle(1) = L_PAGETITLE_QUOTA_QUOTA_TEXT
  58. '
  59. ' Create a Property Page
  60. Call SA_CreatePage( aPageTitle, "", PT_PROPERTY, page )
  61. '
  62. ' Serve the page
  63. Call SA_ShowPage( page )
  64. '======================================================
  65. ' Web Framework Event Handlers
  66. '======================================================
  67. '---------------------------------------------------------------------
  68. ' Function name: OnInitPage
  69. ' Description: Called to signal first time processing for this page
  70. ' Input Variables: Out: PageIn
  71. ' Out: EventArg
  72. ' Output Variables: None
  73. ' Return Values: TRUE to indicate initialization was successful.
  74. ' FALSE to indicate errors. Returning FALSE will
  75. ' cause the page to be abandoned.
  76. ' Global Variables: None
  77. ' Functions Called: getValuesForDefault
  78. '
  79. ' Get ALL the initial form field settings
  80. '---------------------------------------------------------------------
  81. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  82. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  83. ' Call the function to get the default values
  84. OnInitPage = getValuesForDefault ' True /False
  85. End Function
  86. '---------------------------------------------------------------------
  87. ' Function name: OnServePropertyPage
  88. ' Description: Called when the page needs to be served
  89. ' Input Variables: Out: PageIn
  90. ' Out: EventArg
  91. ' Output Variables: None
  92. ' Return Values: TRUE to indicate no problems occured. FALSE to
  93. ' indicate errors. Returning FALSE will cause the
  94. ' page to be abandoned.
  95. ' Global Variables: In: F_(*) - Form field values
  96. ' In: L_(*) - Text display strings
  97. ' In: G_nRadioChecked - radio to be selected
  98. ' Functions Called: (i)ServeCommonJavaScript, (ii)setUnits
  99. '
  100. ' The UI is served here.
  101. '---------------------------------------------------------------------
  102. Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg)
  103. Call SA_TraceOut(SOURCE_FILE, "OnServePropertyPage")
  104. '
  105. ' Emit Javascript functions required by Web Framework
  106. Call ServeCommonJavaScript()
  107. %>
  108. <table border="0" cellspacing="0" cellpadding="0">
  109. <tr>
  110. <td nowrap colspan="2" class="TasksBody">
  111. <input type="checkbox" class="FormCheckBox" name="chkEnableQuotaMgmt" onClick="JavaScript:CheckToDisableAll(); " <% If F_nChkEnableQuotaMgmt <> CONST_DISABLE_QUOTA_MGMT Then Response.write "CHECKED" Else Response.Write "UNCHECKED" End If %> >
  112. &nbsp;<%=L_ENABLE_QUOTA_MGMT_TEXT %>
  113. </td>
  114. </tr>
  115. <tr>
  116. <td nowrap colspan="2" class="TasksBody">
  117. <input type="checkbox" class="FormCheckBox" name="chkDenyDiskSpace" <% If F_blnChkDenyDiskSpace Then Response.write "CHECKED" Else Response.Write "UNCHECKED" End If %> >
  118. &nbsp;<%=L_DENY_DISK_SPACE_TEXT %>
  119. </td>
  120. </tr>
  121. <tr>
  122. <td colspan="2" class="TasksBody">&nbsp;</td>
  123. </tr>
  124. <tr>
  125. <td colspan="2" nowrap class="TasksBody">
  126. <%=L_SELECT_DEFAULT_QUOTA_TEXT %>
  127. </td>
  128. </tr>
  129. <tr>
  130. <td colspan="2" class="TasksBody">&nbsp;</td>
  131. </tr>
  132. <tr>
  133. <td colspan="2" nowrap class="TasksBody">
  134. <p><input type="radio" class="FormRadioButton" name="donotlimit" value="1" <% If G_nRadioChecked = 1 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:DisableWarnLevel(warndisksize, warndisksizeunits); DisableLimitLevel(limitdisksize, limitdisksizeunits)">&nbsp;<% =L_DONOTLIMITDISKUSAGE_TEXT %></p>
  135. </td>
  136. </tr>
  137. <tr>
  138. <td width="30%" nowrap class="TasksBody">
  139. <input type="radio" class="FormRadioButton" name="donotlimit" value="2" <% If G_nRadioChecked = 2 Then Response.Write "CHECKED" Else Response.write "UNCHECKED" End If %> onClick="JavaScript:EnableWarnDiskSpace(warndisksize,warndisksizeunits); EnableLimitDiskSpace(limitdisksize, limitdisksizeunits) ">&nbsp;<% =L_SETLIMITDISKSPACE_TEXT %>
  140. </td>
  141. <td nowrap class="TasksBody">
  142. <input type="text" name="limitdisksize" value="<% =server.HTMLEncode(SA_EscapeQuotes(F_LimitSize)) %>" size="14" maxlength = "11" class="FormField" onFocus="this.select()" onKeyPress="allownumbers( this )" onChange="validatedisklimit( this, document.frmTask.limitdisksizeunits.value)" >
  143. <select name="limitdisksizeunits" size="1" class="FormField" onChange="ClearErr();validatedisklimit( document.frmTask.limitdisksize, this.value )">
  144. <% setUnits(F_LimitUnits) %>
  145. </select>
  146. </td>
  147. </tr>
  148. <tr>
  149. <td width="30%" nowrap class="TasksBody">
  150. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<% =L_SETWARNINGLEVEL_TEXT %>
  151. </td>
  152. <td nowrap class="TasksBody">
  153. <input type="text" name="warndisksize" value="<%=server.HTMLEncode(SA_EscapeQuotes(F_ThresholdSize)) %>" size="14" maxlength="11" class="FormField" onFocus="this.select()" onKeyPress="allownumbers( this )" onChange="validatedisklimit( this, document.frmTask.warndisksizeunits.value )" >
  154. <select name="warndisksizeunits" size="1" class="FormField" onChange="ClearErr();validatedisklimit(document.frmTask.warndisksize, this.value)">
  155. <% setUnits(F_ThresholdUnits) %>
  156. </select>
  157. </td>
  158. </tr>
  159. <tr>
  160. <td colspan="2" class="TasksBody">&nbsp;</td>
  161. </tr>
  162. <tr>
  163. <td colspan="2" nowrap class="TasksBody">
  164. <%=L_SELECT_QUOTA_LOGGING_TEXT %>
  165. </td>
  166. </tr>
  167. <tr>
  168. <td nowrap colspan="2" class="TasksBody">
  169. <input type="checkbox" class="FormCheckBox" name="chkEnableLogEventExceedQuotaLimit" <% If F_blnChkEnableLogEventExceedQuotaLimit Then Response.write "CHECKED" Else Response.Write "UNCHECKED" End If %> >
  170. &nbsp;<%=L_ENABLE_QUOTA_LOGGING_TEXT %>
  171. </td>
  172. </tr>
  173. <tr>
  174. <td nowrap colspan="2" class="TasksBody">
  175. <input type="checkbox" class="FormCheckBox" name="chkEnableLogEventExceedWarningLimit" <% If F_blnChkEnableLogEventExceedWarningLimit Then Response.write "CHECKED" Else Response.Write "UNCHECKED" End If %> >
  176. &nbsp;<%=L_ENABLE_WARNING_LOGGING_TEXT %>
  177. </td>
  178. </tr>
  179. </table>
  180. <input name="volume" type="hidden" value="<% =F_strVolName %>">
  181. <%
  182. OnServePropertyPage = TRUE
  183. End Function
  184. '---------------------------------------------------------------------
  185. ' Function name: OnPostBackPage
  186. ' Description: Called to signal that the page has been posted-back
  187. ' Input Variables: Out: PageIn
  188. ' Out: EventArg
  189. ' Output Variables: None
  190. ' Return Values: TRUE to indicate success. FALSE to indicate errors.
  191. ' Returning FALSE will cause the page to be abandoned.
  192. ' Global Variables: Out: F_(*) - Form values
  193. ' Out: G_nRadioChecked - the selected radio value
  194. '
  195. ' Collect the form data vales.
  196. '---------------------------------------------------------------------
  197. Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  198. Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage")
  199. ' get the volume for which quota is set
  200. F_strVolName = Request.Form("volume")
  201. ' initialize the quota state to "Disabled"
  202. F_nChkEnableQuotaMgmt = CONST_DISABLE_QUOTA_MGMT
  203. If UCASE(Request.Form("chkEnableQuotaMgmt")) = "ON" Then
  204. ' If the checkBox is Checked, Enable the Quota State
  205. F_nChkEnableQuotaMgmt = CONST_ENABLE_QUOTA_MGMT
  206. End If
  207. ' initialize the "Enforce Quota Limit" to false
  208. F_blnChkDenyDiskSpace = False
  209. If UCASE(Request.Form("chkDenyDiskSpace")) = "ON" Then
  210. ' If the checkBox is checked, set to true
  211. F_blnChkDenyDiskSpace = True
  212. End if
  213. ' initialize the "Log when user exceeds Quota limit" to false
  214. F_blnChkEnableLogEventExceedQuotaLimit = False
  215. If UCASE(Request.Form("chkEnableLogEventExceedQuotaLimit")) = "ON" Then
  216. ' If checkBox is checked, Enable the logging
  217. F_blnChkEnableLogEventExceedQuotaLimit = True
  218. End if
  219. ' initialize the "Log if user exceeds WarningLimit" to false
  220. F_blnChkEnableLogEventExceedWarningLimit = False
  221. If UCASE(Request.Form("chkEnableLogEventExceedWarningLimit")) = "ON" Then
  222. ' if the checkBox is checked, Enable the logging
  223. F_blnChkEnableLogEventExceedWarningLimit = True
  224. End if
  225. ' get the selected radioButton value
  226. G_nRadioChecked = Request.Form("donotlimit")
  227. ' get the Disk Limit Size and its Units
  228. F_LimitSize = Request.Form("limitdisksize")
  229. F_LimitUnits = Request.Form("limitdisksizeunits")
  230. ' get the Warning Limit Size and its Units
  231. F_ThresholdSize = Request.Form("warndisksize")
  232. F_ThresholdUnits = Request.Form("warndisksizeunits")
  233. If Len(Trim(F_strVolName)) = 0 Then
  234. ' volume is not retrieved. cannot proceed.
  235. OnPostBackPage = False
  236. Else
  237. ' return True
  238. OnPostBackPage = TRUE
  239. End If
  240. End Function
  241. '---------------------------------------------------------------------
  242. ' Function name: OnSubmitPage
  243. ' Description: To process the submit request
  244. ' Input Variables: Out: PageIn
  245. ' Out: EventArg
  246. ' Output Variables: None
  247. ' Return Values: TRUE if the submit was successful, FALSE to indicate error(s).
  248. ' Returning FALSE will cause the page to be served again using
  249. ' a call to OnServePropertyPage.
  250. ' Returning FALSE will display error message.
  251. ' Global Variables: None
  252. ' Functions Called: UpdateQuotaValues
  253. '
  254. ' Updates the Quota Values for the given volume
  255. '---------------------------------------------------------------------
  256. Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  257. Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage")
  258. ' Call UpdateQuotaValues to update the values.
  259. ' If any error occurs,the error message is set in the function.
  260. OnSubmitPage = UpdateQuotaValues ' returns: True/False
  261. End Function
  262. '---------------------------------------------------------------------
  263. ' Function name: OnClosePage
  264. ' Description: to perform clean-up processing
  265. ' Input Variables: Out: PageIn
  266. ' Out: EventArg
  267. ' Output Variables: None
  268. ' Return Values: TRUE to allow close, FALSE to prevent close. Returning FALSE
  269. ' will result in a call to OnServePropertyPage.
  270. ' Global Variables: None
  271. '
  272. ' Called when the page is about to be closed.
  273. '---------------------------------------------------------------------
  274. Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  275. Call SA_TraceOut(SOURCE_FILE, "OnClosePage")
  276. ' no processing required here. Return True
  277. OnClosePage = TRUE
  278. End Function
  279. '======================================================
  280. ' Private Functions
  281. '======================================================
  282. '---------------------------------------------------------------------
  283. ' Function name: ServeCommonJavaScript
  284. ' Description: Serve JavaScript that is required for this page type
  285. ' Input Variables: None
  286. ' Output Variables: None
  287. ' Return Values: None
  288. ' Global Variables: L_(*) - Error messages displayed on the client side
  289. '
  290. ' This contains the Client-Side script required for the page.
  291. '---------------------------------------------------------------------
  292. Function ServeCommonJavaScript()
  293. %>
  294. <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  295. </script>
  296. <script language="JavaScript" src="inc_quotas.js">
  297. </script>
  298. <script language="JavaScript">
  299. //
  300. // Microsoft Server Appliance Web Framework Support Functions
  301. // Copyright (c) Microsoft Corporation. All rights reserved.
  302. //
  303. // to perform first time initialization.
  304. function Init()
  305. {
  306. // enable cancel in case of any server side error
  307. EnableCancel();
  308. if(document.frmTask.chkEnableQuotaMgmt.checked == false)
  309. {
  310. // to disable all other controls if Quota Management is disabled
  311. disableFields();
  312. return;
  313. }
  314. if ( document.frmTask.donotlimit[0].checked )
  315. {
  316. document.frmTask.warndisksize.disabled = true;
  317. document.frmTask.limitdisksize.disabled = true;
  318. document.frmTask.warndisksizeunits.disabled = true;
  319. document.frmTask.limitdisksizeunits.disabled = true;
  320. }
  321. else
  322. {
  323. if ( document.frmTask.donotlimit[1].checked )
  324. {
  325. document.frmTask.limitdisksize.select();
  326. }
  327. else
  328. {
  329. // disable all except cancel button
  330. DisableOK() ;
  331. document.frmTask.donotlimit[0].disabled = true;
  332. document.frmTask.donotlimit[1].disabled = true;
  333. document.frmTask.warndisksize.disabled = true;
  334. document.frmTask.limitdisksize.disabled = true;
  335. document.frmTask.warndisksizeunits.disabled = true;
  336. document.frmTask.limitdisksizeunits.disabled = true;
  337. document.frmTask.donotlimit[0].checked = false;
  338. }
  339. }
  340. }
  341. // to validate user input. Returning false will cause the submit to abort.
  342. // Returns: True if the page is OK, false if error(s) exist.
  343. function ValidatePage()
  344. {
  345. var objlimitSize = document.frmTask.limitdisksize ;
  346. var objwarnSize = document.frmTask.warndisksize ;
  347. var objlimitUnits = document.frmTask.limitdisksizeunits ;
  348. var objwarnUnits = document.frmTask.warndisksizeunits ;
  349. if ( document.frmTask.donotlimit[1].checked )
  350. {
  351. // validate the Limit Size value
  352. if(!isSizeValidDataType(objlimitSize.value) )
  353. {
  354. SA_DisplayErr('<% =Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDDATATYPE_ERRORMESSAGE))%>');
  355. document.frmTask.onkeypress = ClearErr;
  356. selectFocus( objlimitSize );
  357. return false;
  358. }
  359. // validate the LimitSize Units
  360. if (!checkSizeAndUnits(objlimitSize.value, objlimitUnits.value) )
  361. {
  362. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_SIZEOUTOFBOUND_ERRORMESSAGE))%>');
  363. document.frmTask.onkeypress = ClearErr;
  364. selectFocus( objlimitSize );
  365. return false;
  366. }
  367. // validate the Warning Limit
  368. if(!isSizeValidDataType(objwarnSize.value) )
  369. {
  370. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_INVALIDDATATYPE_ERRORMESSAGE))%>');
  371. document.frmTask.onkeypress = ClearErr;
  372. selectFocus(objwarnSize);
  373. return false;
  374. }
  375. // validate the Warning Limit Units
  376. if (!checkSizeAndUnits(objwarnSize.value, objwarnUnits.value) )
  377. {
  378. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_SIZEOUTOFBOUND_ERRORMESSAGE)) %>');
  379. document.frmTask.onkeypress = ClearErr;
  380. selectFocus( objwarnSize );
  381. return false;
  382. }
  383. // verify the warning level. Must be less than limit.
  384. if(isWarningMoreThanLimit(objlimitSize,objlimitUnits,objwarnSize,objwarnUnits))
  385. {
  386. SA_DisplayErr('<%=Server.HTMLEncode(SA_EscapeQuotes(L_WARNING_MORETHAN_LIMIT_ERRORMESSAGE))%>');
  387. document.frmTask.onkeypress = ClearErr;
  388. selectFocus( objwarnSize );
  389. return false;
  390. }
  391. }
  392. // if the Limit values are Less than 1 KB, set them to 1 KB
  393. validatedisklimit( objlimitSize, objlimitUnits.value);
  394. validatedisklimit( objwarnSize, objwarnUnits.value);
  395. return true;
  396. }
  397. // to modify hidden form fields
  398. function SetData()
  399. {
  400. // no hidden values to update here
  401. }
  402. // to enable or disable the form controls onClick of the CheckBox
  403. function CheckToDisableAll()
  404. {
  405. // If Disk quota mgmt is disabled we need to disable all fields
  406. if ( document.frmTask.chkEnableQuotaMgmt.checked == false )
  407. {
  408. // disable the fields
  409. disableFields();
  410. }
  411. else
  412. {
  413. // Disk quota mgmt is enabled we need to enable all fields
  414. enableFields();
  415. }
  416. }
  417. // to disable the fields
  418. function disableFields()
  419. {
  420. document.frmTask.chkDenyDiskSpace.checked = false;
  421. document.frmTask.chkDenyDiskSpace.disabled = true;
  422. document.frmTask.donotlimit[0].checked = true;
  423. document.frmTask.donotlimit[0].disabled = true;
  424. document.frmTask.donotlimit[1].disabled = true;
  425. document.frmTask.chkEnableLogEventExceedQuotaLimit.checked = false;
  426. document.frmTask.chkEnableLogEventExceedQuotaLimit.disabled = true;
  427. document.frmTask.chkEnableLogEventExceedWarningLimit.checked = false;
  428. document.frmTask.chkEnableLogEventExceedWarningLimit.disabled = true;
  429. document.frmTask.warndisksize.disabled = true;
  430. document.frmTask.warndisksizeunits.disabled = true;
  431. document.frmTask.limitdisksize.disabled = true;
  432. document.frmTask.limitdisksizeunits.disabled = true;
  433. }
  434. // to enable the fields
  435. function enableFields()
  436. {
  437. document.frmTask.chkDenyDiskSpace.checked = false;
  438. document.frmTask.chkDenyDiskSpace.disabled = false;
  439. document.frmTask.donotlimit[1].checked = true;
  440. document.frmTask.donotlimit[0].disabled = false;
  441. document.frmTask.donotlimit[1].disabled = false;
  442. if( isNaN(document.frmTask.limitdisksize.value) )
  443. document.frmTask.limitdisksize.value = "1" ;
  444. if( isNaN(document.frmTask.warndisksize.value) )
  445. document.frmTask.warndisksize.value = "1" ;
  446. document.frmTask.chkEnableLogEventExceedQuotaLimit.checked = false;
  447. document.frmTask.chkEnableLogEventExceedQuotaLimit.disabled = false;
  448. document.frmTask.chkEnableLogEventExceedWarningLimit.checked = false;
  449. document.frmTask.chkEnableLogEventExceedWarningLimit.disabled = false;
  450. document.frmTask.warndisksize.disabled = false;
  451. document.frmTask.warndisksizeunits.disabled = false;
  452. document.frmTask.limitdisksize.disabled = false;
  453. document.frmTask.limitdisksizeunits.disabled = false;
  454. }
  455. </script>
  456. <%
  457. End Function
  458. '---------------------------------------------------------------------
  459. ' Function name: getValuesForDefault
  460. ' Description: get the default values for the quota settings
  461. ' Input Variables: None
  462. ' Output Variables: None
  463. ' Return Values: True - if success. False if any error(s) occur
  464. ' Global Variables: Out: F_(*) - Form field values
  465. ' Out: G_nRadioChecked - radioButton to select
  466. ' In: L_(*) - Error messages
  467. ' Functions Called:
  468. ' (i)getQuotaLimitRadioForDefault (iv)getThresholdSizeForDefault
  469. ' (ii)getLimitSizeForDefault (v)getThresholdSizeUnitsForDefault
  470. '(iii)getLimitUnitsForDefault
  471. '
  472. ' Calls the failure page if values could not be retrieved
  473. '---------------------------------------------------------------------
  474. Function getValuesForDefault
  475. On Error Resume Next
  476. Err.Clear
  477. Dim objQuotas ' the quota object
  478. ' create the quota object and initialize for the required Volume
  479. Set objQuotas = CreateObject("Microsoft.DiskQuota.1")
  480. objQuotas.Initialize F_strVolName &"\", 1
  481. If Err.number <> 0 Then
  482. ' cannot proceed. Display failure page.
  483. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE)
  484. End If
  485. ' get the Quota Management State. Possible values:
  486. ' (i)CONST_ENABLE_QUOTA_MGMT - Enable Quota Management
  487. ' (ii)CONST_ENFORCE_QUOTA_LIMIT - Disable Quota Mangement
  488. ' (iii)CONST_DISABLE_QUOTA_MGMT - Enforce Quota Management
  489. F_nChkEnableQuotaMgmt = objQuotas.QuotaState
  490. ' initialize the "Enforce Quota Management" to False
  491. F_blnChkDenyDiskSpace = False
  492. If objQuotas.QuotaState = CONST_ENFORCE_QUOTA_LIMIT Then
  493. ' set to True if enforced
  494. F_blnChkDenyDiskSpace = True
  495. End If
  496. ' get the "Log if user exceeds quota limit" value. True or False
  497. F_blnChkEnableLogEventExceedQuotaLimit = objQuotas.LogQuotaLimit
  498. ' get the "Log if user exceeds Warning limit" value. True or False
  499. F_blnChkEnableLogEventExceedWarningLimit = objQuotas.LogQuotaThreshold
  500. ' get the radio button to be selected - 1 or 2
  501. G_nRadioChecked = getQuotaLimitRadioForDefault(objQuotas)
  502. ' Compute Default Disk Limit and its units
  503. F_LimitSize = getLimitSizeForDefault(objQuotas)
  504. F_LimitUnits = getLimitUnitsForDefault(objQuotas)
  505. ' Compute Default Warning Limit and its units
  506. F_ThresholdSize = getThresholdSizeForDefault(objQuotas)
  507. F_ThresholdUnits = getThresholdSizeUnitsForDefault(objQuotas)
  508. If Err.number <> 0 Then
  509. ' in case of any error return False
  510. getValuesForDefault = False
  511. Err.Clear ' stop further error propagation
  512. Exit Function
  513. End If
  514. getValuesForDefault = True
  515. ' clean up
  516. Set objQuotas = Nothing
  517. End Function
  518. '---------------------------------------------------------------------
  519. ' Function name: UpdateQuotaValues
  520. ' Description: Set the default values for the quota settings
  521. ' Input Variables: None
  522. ' Output Variables: None
  523. ' Return Values: True - if success. False if any error(s) occur
  524. ' Global Variables: In: F_(*) - Form field values
  525. ' In: L_(*) - Error messages
  526. ' In: G_nRadioChecked - radioButton to select
  527. ' Functions Called: (i)setDefaultQuotaLimit, (ii)setDefaultThreshold
  528. '
  529. ' The error message is set incase error occurs
  530. '---------------------------------------------------------------------
  531. Function UpdateQuotaValues
  532. On Error Resume Next
  533. Err.Clear
  534. Dim objQuotas ' the quota object
  535. ' create the quota object and initialize for the required Volume
  536. Set objQuotas = CreateObject("Microsoft.DiskQuota.1")
  537. objQuotas.Initialize F_strVolName &"\", 1
  538. If Err.number <> 0 Then
  539. ' cannot proceed. Display failure page.
  540. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE)
  541. End If
  542. ' update the Quota State property
  543. objQuotas.QuotaState = F_nChkEnableQuotaMgmt
  544. ' update the "Enforce Quota Limit" property
  545. If F_blnChkDenyDiskSpace Then
  546. objQuotas.QuotaState = CONST_ENFORCE_QUOTA_LIMIT
  547. End if
  548. ' update "Enable Logging when user exceeds disk limit"
  549. objQuotas.LogQuotaLimit = F_blnChkEnableLogEventExceedQuotaLimit
  550. ' enable logging when user exceeds warning limit
  551. objQuotas.LogQuotaThreshold = F_blnChkEnableLogEventExceedWarningLimit
  552. ' check if any error occured
  553. If Err.number <> 0 Then
  554. SA_SetErrMsg L_QUOTA_UPDATE_FAIL_ERRORMESSAGE & " (" & Hex(Err.Number) & ")"
  555. Err.Clear ' stop further propagation
  556. UpdateQuotaValues = False
  557. Exit Function
  558. End If
  559. ' If "Do not limit disk usage" is selected, Set the DiskLimit and
  560. ' WarningLimit to "No Limit"
  561. If CInt(G_nRadioChecked) = CInt(CONST_RADIO_DONOT_LIMIT_DISKUSAGE) Then
  562. F_LimitSize = CONST_NO_LIMIT
  563. F_ThresholdSize = CONST_NO_LIMIT
  564. End If
  565. ' set the DiskLimit size for the Quota
  566. If NOT setDefaultQuotaLimit(objQuotas, F_LimitSize, F_LimitUnits) Then
  567. SA_SetErrMsg L_MAXLIMITNOTSET_ERRORMESSAGE & " (" & Hex(Err.Number) & ")"
  568. Err.Clear ' stop further propagation
  569. UpdateQuotaValues = False
  570. Exit Function
  571. End If
  572. ' set the WarningLimit size for the Quota
  573. If NOT setDefaultThreshold(objQuotas, F_ThresholdSize, F_ThresholdUnits) Then
  574. SA_SetErrMsg L_WARNINGLIMITNOTSET_ERRORMESSAGE & " (" & Hex(Err.Number) & ")"
  575. Err.Clear ' stop further propagation
  576. UpdateQuotaValues = False
  577. Exit Function
  578. End If
  579. ' all values updated. return True
  580. UpdateQuotaValues = True
  581. ' clean up
  582. Set objQuotas = Nothing
  583. End Function
  584. '---------------------------------------------------------------------
  585. ' Function name: setDefaultQuotaLimit
  586. ' Description: set the Default Quota limit
  587. ' Input Variables: (out)objQuotas
  588. ' (in) nDiskLimit
  589. ' (in) strUnits
  590. ' Output Variables: (out) objQuotas
  591. ' Return Values: True/ False
  592. ' Global Variables: None
  593. ' Functions Called: ChangeToFloat
  594. '---------------------------------------------------------------------
  595. Function setDefaultQuotaLimit(ByRef objQuotas, nDiskLimit, strUnits)
  596. On Error Resume Next
  597. Err.Clear
  598. Dim nDiskLimitToSet ' the disk limit to set
  599. If nDiskLimit <> CONST_NO_LIMIT Then
  600. 'Added 0.001 round the value of disk Limit
  601. nDiskLimitToSet = ChangeToFloat(nDiskLimit + 0.001, strUnits)
  602. If nDiskLimitToSet < 1024 Then
  603. nDiskLimitToSet = 1024 ' must be minimum 1 KB
  604. End if
  605. Else
  606. nDiskLimitToSet = nDiskLimit
  607. End If
  608. ' the disk values are converted to Bytes and then set to the object
  609. objQuotas.DefaultQuotaLimit = nDiskLimitToSet
  610. If Err.number <> 0 Then
  611. setDefaultQuotaLimit = FALSE
  612. Else
  613. setDefaultQuotaLimit = TRUE
  614. End If
  615. End Function
  616. '---------------------------------------------------------------------
  617. ' Function name: setDefaultThreshold
  618. ' Description: set the Default Quota Threshold
  619. ' Input Variables: (out)objQuotas
  620. ' (in) nThresholdLimit
  621. ' (in) strUnits
  622. ' Output Variables: (out) objQuotas
  623. ' Return Values: True/ False
  624. ' Global Variables: None
  625. ' Functions Called: ChangeToFloat
  626. '---------------------------------------------------------------------
  627. Function setDefaultThreshold(ByRef objQuotas, nThresholdLimit, strUnits)
  628. On Error Resume Next
  629. Err.Clear
  630. Dim nThresholdLimitToSet ' the warning limit to set
  631. If nThresholdLimit <> CONST_NO_LIMIT Then
  632. 'Added 0.001 round the value of Warning Limit
  633. nThresholdLimitToSet = ChangeToFloat( nThresholdLimit + 0.001, strUnits )
  634. If nThresholdLimitToSet < 1024 Then
  635. nThresholdLimitToSet = 1024 ' must be minimum 1 KB
  636. End if
  637. Else
  638. nThresholdLimitToSet = nThresholdLimit
  639. End If
  640. ' convert the value into Bytes abd set to object
  641. objQuotas.DefaultQuotaThreshold = nThresholdLimitToSet
  642. If Err.number <> 0 Then
  643. setDefaultThreshold = False
  644. Else
  645. setDefaultThreshold = True
  646. End If
  647. End Function
  648. '---------------------------------------------------------------------
  649. ' Procedure name: getVolumeName
  650. ' Description: get volume name as obtained from previous OTS page
  651. ' Input Variables: None
  652. ' Output Variables: None
  653. ' Return Values: None
  654. ' Global Variables: Out: F_strVolName - the volume to set quota values on
  655. '---------------------------------------------------------------------
  656. Sub getVolumeName()
  657. Dim strItemKey ' the selected value in the OTS page
  658. Dim i ' to loop
  659. Dim iCount ' the count of entries selected
  660. ' first get from the form (in case form re-submitted)
  661. F_strVolName = Request.Form("volume")
  662. If Len(Trim(F_strVolName)) = 0 Then
  663. ' get the selected value from the OTS
  664. iCount = OTS_GetTableSelectionCount("")
  665. For i = 1 to iCount
  666. Call OTS_GetTableSelection("", i, strItemKey)
  667. Next
  668. ' get the last selected entry
  669. F_strVolName = strItemKey
  670. End If
  671. End Sub
  672. %>