<%@ Language=VBScript %> <% Option Explicit %> <% '------------------------------------------------------------------------- ' quota_new.asp: create a new quota entry ' ' Copyright (c) Microsoft Corporation. All rights reserved. ' ' Date Description ' 17-Jan-01 Creation date ' 15-Mar-01 Ported to 2.0 '------------------------------------------------------------------------- %> <% '------------------------------------------------------------------------- ' Global Variables '------------------------------------------------------------------------- Dim G_nRadioChecked ' to set radioButton values - contains 1 or 2 only Dim SOURCE_FILE ' the source file name used while Tracing SOURCE_FILE = SA_GetScriptFileName() '------------------------------------------------------------------------- ' Global Form Variables '------------------------------------------------------------------------- Dim F_strVolName ' Volume Name Dim F_strUsername ' to user Name Dim F_LimitSize ' Disk limit size - textBox value Dim F_LimitUnits ' Disk limit size units - comboBox value Dim F_ThresholdSize ' the warning level set for the user - textBox value Dim F_ThresholdUnits ' the units for the warning level set - comboBox Value Dim F_strUserList ' List of users to be displayed Dim F_strDisplayUserName ' to display user name in the TextBox '====================================================== ' Entry point '====================================================== Dim page Dim aPageTitle(2) aPageTitle(0) = L_BROWSERCAPTION_QUOTANEW_TEXT aPageTitle(1) = L_TASKTITLE_NEW_TEXT ' ' Create a Property Page Call SA_CreatePage( aPageTitle, "", PT_PROPERTY, page ) ' ' Serve the page Call SA_ShowPage( page ) '====================================================== ' Web Framework Event Handlers '====================================================== '--------------------------------------------------------------------- ' Function name: OnInitPage ' Description: Called to signal first time processing for this page ' Input Variables: Out: PageIn ' Out: EventArg ' Output Variables: None ' Return Values: TRUE to indicate initialization was successful. ' FALSE to indicate errors. Returning FALSE will ' cause the page to be abandoned. ' Global Variables: None ' Functions Called: getValuesForDefault ' ' Get ALL the initial form field settings '--------------------------------------------------------------------- Public Function OnInitPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnInitPage") F_strVolName = Request.QueryString("driveletter") Call SA_MungeURL(mstrReturnURL,"driveletter",F_strVolName) ' Call the function to get the default values OnInitPage = getValuesForDefault ' True /False End Function '--------------------------------------------------------------------- ' Function name: OnServePropertyPage ' Description: Called when the page needs to be served ' Input Variables: Out: PageIn ' Out: EventArg ' Output Variables: None ' Return Values: TRUE to indicate no problems occured. FALSE to ' indicate errors. Returning FALSE will cause the ' page to be abandoned. ' Global Variables: In: F_(*) - Form field values ' In: L_(*) - Text display strings ' In: G_nRadioChecked - radio to be selected ' Functions Called: (i)ServeCommonJavaScript, (ii)setUnits ' (iii)ServetoListBox ' ' The UI is served here. '--------------------------------------------------------------------- Public Function OnServePropertyPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnServePropertyPage") ' ' Emit Javascript functions required by Web Framework Call ServeCommonJavaScript() %>
<%=L_DESCRIPTION_NEW_TEXT%>

onClick="JavaScript:DisableWarnLevel(warndisksize,warndisksizeunits); DisableLimitLevel(limitdisksize,limitdisksizeunits)"> <% =L_DONOTLIMITDISKUSAGE_TEXT %>
onClick="JavaScript:EnableWarnDiskSpace(warndisksize, warndisksizeunits); EnableLimitDiskSpace(limitdisksize,limitdisksizeunits) "> <% =L_SETLIMITDISKSPACE_TEXT %>
      <% =L_SETWARNINGLEVEL_TEXT %>
<% OnServePropertyPage = TRUE End Function '--------------------------------------------------------------------- ' Function name: OnPostBackPage ' Description: Called to signal that the page has been posted-back ' Input Variables: Out: PageIn ' Out: EventArg ' Output Variables: None ' Return Values: TRUE to indicate success. FALSE to indicate errors. ' Returning FALSE will cause the page to be abandoned. ' Global Variables: Out: F_(*) - Form values ' Out: G_nRadioChecked - the selected radio value ' ' Collect the form data vales. '--------------------------------------------------------------------- Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnPostBackPage") Dim objService ' for the WMI Connection ' get user and volume values F_strVolName = Request.Form("volume") F_strUsername = Request.Form("user") ' get the display user name F_strDisplayUserName = Request.Form("txtDomainUser") ' get the radiButton selected G_nRadioChecked = Request.Form("donotlimit") ' get the Limit Size value and its units F_LimitSize = Request.Form("limitdisksize") F_LimitUnits = Request.Form("limitdisksizeunits") ' get the warning limit and its units F_ThresholdSize = Request.Form("warndisksize") F_ThresholdUnits = Request.Form("warndisksizeunits") ' get the wmi connection Set objService = GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) ' get the List of users to be displayed in the ListBox F_strUserList =getLocalUsersListEx(objService , 2)'Calling only users ' clean up Set objService = Nothing If Len(Trim(F_strVolName)) = 0 OR Len(Trim(F_strUsername)) = 0 Then ' user or volume info not found. Cannot process further. OnPostBackPage = FALSE Else OnPostBackPage = TRUE End If End Function '--------------------------------------------------------------------- ' Function name: OnSubmitPage ' Description: To process the submit request ' Input Variables: Out: PageIn ' Out: EventArg ' Output Variables: None ' Return Values: TRUE if the submit was successful, FALSE to indicate error(s). ' Returning FALSE will cause the page to be served again using ' a call to OnServePropertyPage. ' Returning FALSE will display error message. ' Global Variables: None ' Functions Called: updateValuesForUser ' ' Updates the Quota Values for the given volume '--------------------------------------------------------------------- Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnSubmitPage") ' Call updateValuesForUser to update the values for the user quota ' If any error occurs,the error message is set in the function. OnSubmitPage = updateValuesForUser ' returns True/False End Function '--------------------------------------------------------------------- ' Function name: OnClosePage ' Description: to perform clean-up processing ' Input Variables: Out: PageIn ' Out: EventArg ' Output Variables: None ' Return Values: TRUE to allow close, FALSE to prevent close. Returning FALSE ' will result in a call to OnServePropertyPage. ' Global Variables: None ' ' Called when the page is about to be closed. '--------------------------------------------------------------------- Public Function OnClosePage(ByRef PageIn, ByRef EventArg) Call SA_TraceOut(SOURCE_FILE, "OnClosePage") ' no processing required here. Return True OnClosePage = TRUE End Function '====================================================== ' Private Functions '====================================================== '--------------------------------------------------------------------- ' Function name: ServeCommonJavaScript ' Description: Serve JavaScript that is required for this page type ' Input Variables: None ' Output Variables: None ' Return Values: None ' Global Variables: L_(*) - Error messages displayed on the client side ' ' This contains the Client-Side script required for the page. '--------------------------------------------------------------------- Function ServeCommonJavaScript() %> <% End Function '--------------------------------------------------------------------- ' Procedure Name: getValuesForDefault ' Description: gets the Default Quota entry values ' Input Variables: None ' Output Variables: None ' Returns: None ' Global Variables: In: F_strVolName ' Out: F_ThresholdSize ' Out: F_ThresholdUnits ' Out: F_LimitSize ' Out: F_LimitUnits ' Out: F_strUserList ' Out: G_nRadioChecked ' Functions Called: ' (i)getQuotaLimitRadioForDefault (iv)getLimitSizeForDefault ' (ii)getThresholdSizeForDefault (v)getLimitUnitsForDefault ' (iii)getThresholdSizeUnitsForDefault (vi)getLocalUsersOnlyList ' ' For the new user display the default quota values as initial values. '--------------------------------------------------------------------- Function getValuesForDefault On Error Resume Next Err.Clear Dim objQuotas ' the quota object Dim objService ' for WMI Connection F_strDisplayUserName = "" F_strUserName = "" ' get the wmi connection Set objService=GetWMIConnection(CONST_WMI_WIN32_NAMESPACE) ' get the List of users to be displayed in the ListBox F_strUserList =getLocalUsersListEx(objService , 2)'Calling only users Set objService = Nothing ' clean up ' create the quota object and initialize for the required Volume Set objQuotas = CreateObject("Microsoft.DiskQuota.1") objQuotas.Initialize F_strVolName & "\", 1 If Err.number <> 0 Then ' cannot proceed. Display failure page. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE) End If ' get the radioButton value to be selected - 1 or 2 only G_nRadioChecked = getQuotaLimitRadioForDefault(objQuotas) ' Compute Default Disk Limit and its units F_LimitSize = getLimitSizeForDefault(objQuotas) F_LimitUnits = getLimitUnitsForDefault(objQuotas) ' Compute Default Warning Limit and its units F_ThresholdSize = getThresholdSizeForDefault(objQuotas) F_ThresholdUnits = getThresholdSizeUnitsForDefault(objQuotas) If Err.number <> 0 Then ' error getValuesForDefault = False Else getValuesForDefault = True End If ' clean up Set objQuotas = Nothing End Function '--------------------------------------------------------------------- ' Procedure Name: updateValuesForUser ' Description: Set the quota values for the given user ' Input Variables: None ' Output Variables: None ' Returns: True - if the values are updated ' False - if values could not be updated ' Global Variables: In: F_strVolName ' In: F_strUsername ' Out: F_ThresholdSize ' Out: F_ThresholdUnits ' Out: F_LimitSize ' Out: F_LimitUnits ' In: G_nRadioChecked ' In: L_(*) ' Functions Called: (i) setUserQuotaLimit ' (ii) setUserThreshold '--------------------------------------------------------------------- Function updateValuesForUser On Error Resume Next Err.Clear Dim objQuotas ' the quota object Dim objUser ' the quota user object Dim blnUserFound ' to verify if the user is found Dim L_DUPLICATEUSER_ERRORMESSAGE Dim L_QUOTAUSERNOTFOUND_ERRORMESSAGE Dim arrVarReplacementStrings(1) ' create the quota object and initialize for the required Volume Set objQuotas = CreateObject("Microsoft.DiskQuota.1") objQuotas.Initialize F_strVolName & "\", 1 objQuotas.UserNameResolution = 1 'wait for names If Err.number <> 0 Then ' cannot proceed. Display failure page. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE) End If ' check if user already has an entry blnUserFound = False For Each objUser In objQuotas If LCase(Trim(F_strUsername)) = LCase(Trim(objUser.LogonName)) Then ' user found blnUserFound = True End If Next If blnUserFound Then ' duplicate entry arrVarReplacementStrings(0) = F_strUsername L_DUPLICATEUSER_ERRORMESSAGE = SA_GetLocString("diskmsg.dll", "C03E0068", arrVarReplacementStrings) SA_SetErrMsg L_DUPLICATEUSER_ERRORMESSAGE updateValuesForUser = False Exit Function End If ' add the new user entry Set objUser = objQuotas.AddUser( F_strUserName ) ' If user is invalid, an error will occur If Err.number <> 0 Then arrVarReplacementStrings(0) = F_strUsername L_QUOTAUSERNOTFOUND_ERRORMESSAGE = SA_GetLocString("diskmsg.dll", "C03E0069", arrVarReplacementStrings) SA_SetErrMsg L_QUOTAUSERNOTFOUND_ERRORMESSAGE & "( " & Hex(Err.number) & " )" Err.Clear ' stop error propagation updateValuesForUser = False Exit Function End If ' verify the radio option checked If CInt(G_nRadioChecked) = CInt(CONST_RADIO_DONOT_LIMIT_DISKUSAGE) Then ' "Do not limit disk usage is selected. Set values of DiskLimit ' and WarningLimit to "No Limit" F_LimitSize = CONST_NO_LIMIT F_ThresholdSize = CONST_NO_LIMIT End If ' set the quota limit by calling the function If NOT setUserQuotaLimit(objUser, F_LimitSize, F_LimitUnits) then ' quota limit could not be set. Display error message and exit SA_SetErrMsg L_MAXLIMITNOTSET_ERRORMESSAGE & " ( " & Hex(Err.number) & " )" Err.Clear ' stop the error propagation updateValuesForUser = False Exit Function End If ' set the warning limit for the user, by calling the function If NOT setUserThreshold(objUser, F_ThresholdSize, F_ThresholdUnits) Then ' warning limit could not be set. display error and exit SA_SetErrMsg L_WARNINGLIMITNOTSET_ERRORMESSAGE & " ( " & Hex(Err.number) & " )" Err.Clear ' stop the error propagation updateValuesForUser = False Exit Function End If ' all values set. return true updateValuesForUser = True ' clean up Set objUser = Nothing Set objQuotas = Nothing End Function %>