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.

831 lines
29 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' quota_quotaentries.asp: lists the quota users set 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 virtual="/admin/ots_main.asp" -->
  16. <!-- #include file="loc_quotas.asp" -->
  17. <!-- #include file="inc_quotas.asp" -->
  18. <%
  19. '-------------------------------------------------------------------------
  20. ' Global Constants
  21. '-------------------------------------------------------------------------
  22. '
  23. ' how many rows are contained in a single page of the OTS table.
  24. Const ROWS_PER_PAGE = 100
  25. ' the column numbers to compare with search column specified
  26. Const COLUMN_LOGONNAME = 0
  27. Const COLUMN_STATUS = 1
  28. Const COLUMN_AMOUNTUSED = 2
  29. Const COLUMN_QUOTALIMIT = 3
  30. Const COLUMN_WARNINGLEVEL = 4
  31. Const PARENT_SELECTION = "ParentSelection"
  32. '-------------------------------------------------------------------------
  33. 'Form Variables
  34. '-------------------------------------------------------------------------
  35. Dim F_strVolName ' the volume quota is set
  36. '-------------------------------------------------------------------------
  37. ' Global Variables
  38. '-------------------------------------------------------------------------
  39. Dim SOURCE_FILE
  40. SOURCE_FILE = SA_GetScriptFileName()
  41. Dim g_bSearchChanged
  42. Dim g_iSearchCol
  43. Dim g_sSearchColValue
  44. Dim g_bPagingInitialized
  45. Dim g_sPageAction
  46. Dim g_iPageMin
  47. Dim g_iPageMax
  48. Dim g_iPageCurrent
  49. Dim g_iSortCol
  50. Dim g_sSortSequence
  51. Dim nReturnValue
  52. Dim g_sParentSelection
  53. '======================================================
  54. ' E N T R Y P O I N T
  55. '======================================================
  56. Dim page
  57. DIM L_APPLIANCE_QUOTAENTRIES_TITLE_TEXT ' page title
  58. ' get the volume name to append to the page title
  59. If Request.QueryString("driveletter") = "" Then
  60. Call OTS_GetTableSelection(SA_DEFAULT, 1, g_sParentSelection)
  61. F_strVolName = g_sParentSelection
  62. Else
  63. F_strVolName = Request.QueryString("driveletter")
  64. End If
  65. ' append the volume name to the title
  66. Dim arrVarReplacementStrings(2)
  67. arrVarReplacementStrings(0) = getVolumeLabelForDrive(F_strVolName)
  68. arrVarReplacementStrings(1) = F_strVolName
  69. L_APPLIANCE_QUOTAENTRIES_TITLE_TEXT = SA_GetLocString("diskmsg.dll", "403E001F", arrVarReplacementStrings)
  70. Dim aPageTitle(2)
  71. aPageTitle(0) = L_BROWSERCAPTION_QUOTAENTRIES_TEXT
  72. aPageTitle(1) = L_APPLIANCE_QUOTAENTRIES_TITLE_TEXT
  73. '
  74. ' Create Page
  75. Call SA_CreatePage( aPageTitle, "", PT_AREA, page )
  76. '
  77. ' Show page
  78. Call SA_ShowPage( page )
  79. '======================================================
  80. ' E V E N T H A N D L E R S
  81. '======================================================
  82. '---------------------------------------------------------------------
  83. ' Function: OnInitPage
  84. '
  85. ' Synopsis: Called to signal first time processing for this page.
  86. ' Used to do first time initialization tasks.
  87. '
  88. ' Returns: TRUE to indicate initialization was successful. FALSE to indicate
  89. ' errors. Returning FALSE will cause the page to be abandoned.
  90. '
  91. '---------------------------------------------------------------------
  92. Public Function OnInitPage(ByRef oPageIn, ByRef oEventArg)
  93. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  94. '
  95. ' Set default values
  96. '
  97. ' Sort second column in ascending sequence
  98. g_iSortCol = 1
  99. g_sSortSequence = "A"
  100. '
  101. ' Paging needs to be initialized
  102. g_bPagingInitialized = FALSE
  103. '
  104. ' Start on page #1
  105. g_iPageCurrent = 1
  106. ' Fetch the parent OTS selection
  107. Call OTS_GetTableSelection(SA_DEFAULT, 1, g_sParentSelection)
  108. F_strVolName = g_sParentSelection
  109. OnInitPage = TRUE
  110. End Function
  111. '---------------------------------------------------------------------
  112. ' Function: OnServeAreaPage
  113. '
  114. ' Synopsis: Called when the page needs to be served. Used to serve content.
  115. '
  116. ' Returns: TRUE to indicate not problems occured. FALSE to indicate errors.
  117. ' Returning FALSE will cause the page to be abandoned.
  118. '
  119. '---------------------------------------------------------------------
  120. Public Function OnServeAreaPage(ByRef oPageIn, ByRef oEventArg)
  121. Dim table ' the OTS table
  122. Dim colFlags ' the column flags to be set
  123. Dim strTaskURL ' the URL assigned to the tasks
  124. Dim iQuotaEntryCountTotal ' total quotaEntries count
  125. Dim iQuotaEntryCountSelected ' quotaEntries selected (satifies search)
  126. Call SA_TraceOut(SOURCE_FILE, "OnServeAreaPage")
  127. '
  128. ' Create the table
  129. table = OTS_CreateTable("", L_DESCRIPTION_QUOTAENTRIES_HEADING_TEXT)
  130. '
  131. ' Must use a uniquely named PKey for the secondary OTS table.
  132. Call OTS_SetTablePKeyName( table, "QuotaUsers")
  133. '
  134. ' If the search criteria changed then we need to recompute the paging range
  135. If ( TRUE = g_bSearchChanged ) Then
  136. '
  137. ' Need to recalculate the paging range
  138. g_bPagingInitialized = FALSE
  139. '
  140. ' Restarting on page #1
  141. g_iPageCurrent = 1
  142. End If
  143. '
  144. ' Create Logon Name column
  145. colFlags = (OTS_COL_SEARCH OR OTS_COL_KEY OR OTS_COL_SORT)
  146. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumnEx( L_COLUMN_LOGONNAME_TEXT, "left", colFlags, 20 ))
  147. If nReturnValue <> OTS_ERR_SUCCESS Then
  148. Call SA_ServeFailurePage(L_ADDCOLUMN_FAIL_ERRORMESSAGE)
  149. End If
  150. '
  151. ' Create Status column
  152. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  153. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumn( L_COLUMN_STATUS_TEXT, "left", colFlags))
  154. If nReturnValue <> OTS_ERR_SUCCESS Then
  155. Call SA_ServeFailurePage(L_ADDCOLUMN_FAIL_ERRORMESSAGE)
  156. End If
  157. '
  158. ' Create Amount Used column
  159. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  160. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumnEx( L_COLUMN_AMOUNTUSED_TEXT, "left", colFlags, 12))
  161. If nReturnValue <> OTS_ERR_SUCCESS Then
  162. Call SA_ServeFailurePage(L_ADDCOLUMN_FAIL_ERRORMESSAGE)
  163. End If
  164. '
  165. ' Create Quota Limit column
  166. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  167. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumnEx( L_COLUMN_QUOTALIMIT_TEXT, "left", colFlags, 12))
  168. If nReturnValue <> OTS_ERR_SUCCESS Then
  169. Call SA_ServeFailurePage(L_ADDCOLUMN_FAIL_ERRORMESSAGE)
  170. End If
  171. '
  172. ' Create Warning Level column
  173. colFlags = (OTS_COL_SEARCH OR OTS_COL_SORT)
  174. nReturnValue = OTS_AddTableColumn(table, OTS_CreateColumnEx( L_COLUMN_WARNINGLEVEL_TEXT, "left", colFlags, 12))
  175. If nReturnValue <> OTS_ERR_SUCCESS Then
  176. Call SA_ServeFailurePage(L_ADDCOLUMN_FAIL_ERRORMESSAGE)
  177. End If
  178. '
  179. ' Add Quota Entries to the table
  180. Call AddItemsToTable(table, iQuotaEntryCountTotal, iQuotaEntryCountSelected)
  181. '
  182. ' Set Tasks section title
  183. Call OTS_SetTableTasksTitle(table, L_COLUMN_TASK_TEXT)
  184. '
  185. ' Add the tasks associated with QuotaEntries
  186. '
  187. ' New quota entry Task is always available (OTS_TaskAlways)
  188. strTaskURL = "quotas/quota_new.asp"
  189. Call SA_MungeURL(strTaskURL,"driveletter",F_strVolName)
  190. Call SA_MungeURL(strTaskURL, PARENT_SELECTION, g_sParentSelection)
  191. Call SA_MungeURL(strTaskURL,"Tab1",GetTab1())
  192. Call SA_MungeURL(strTaskURL,"Tab2",GetTab2())
  193. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_TASK_NEW_TEXT, _
  194. L_TASK_NEW_ROLLOVERTEXT, _
  195. strTaskURL,_
  196. OTS_PT_PROPERTY,_
  197. "OTS_TaskAlways") )
  198. If nReturnValue <> OTS_ERR_SUCCESS Then
  199. Call SA_ServeFailurePage(L_ADDTASK_FAIL_ERRORMESSAGE)
  200. End If
  201. '
  202. ' Delete quotaUser Task is available if one/more task is selected (OTS_TaskAny)
  203. strTaskURL = "quotas/quota_delete.asp"
  204. Call SA_MungeURL(strTaskURL, PARENT_SELECTION, g_sParentSelection)
  205. Call SA_MungeURL(strTaskURL,"Tab1",GetTab1())
  206. Call SA_MungeURL(strTaskURL,"Tab2",GetTab2())
  207. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_TASK_DELETE_TEXT, _
  208. L_TASK_DELETE_ROLLOVERTEXT, _
  209. strTaskURL,_
  210. OTS_PT_PROPERTY,_
  211. "OTS_TaskAny") )
  212. If nReturnValue <> OTS_ERR_SUCCESS Then
  213. Call SA_ServeFailurePage(L_ADDTASK_FAIL_ERRORMESSAGE)
  214. End If
  215. '
  216. ' Properties Task is available if one userQuota entry is selected (OTS_TaskOne)
  217. strTaskURL = "quotas/quota_prop.asp"
  218. Call SA_MungeURL(strTaskURL, PARENT_SELECTION, g_sParentSelection)
  219. Call SA_MungeURL(strTaskURL,"Tab1",GetTab1())
  220. Call SA_MungeURL(strTaskURL,"Tab2",GetTab2())
  221. nReturnValue = OTS_AddTableTask( table, OTS_CreateTaskEx(L_TASK_PROPERTIES_TEXT, _
  222. L_TASK_PROPERTIES_ROLLOVERTEXT, _
  223. strTaskURL,_
  224. OTS_PT_PROPERTY,_
  225. "OTS_TaskOne") )
  226. If nReturnValue <> OTS_ERR_SUCCESS Then
  227. Call SA_ServeFailurePage(L_ADDTASK_FAIL_ERRORMESSAGE)
  228. End If
  229. ' enable paging
  230. Call OTS_EnablePaging(table, TRUE)
  231. ' If paging range needs to be initialised then
  232. ' we need to figure out how many pages we are going to display
  233. If ( FALSE = g_bPagingInitialized ) Then
  234. g_iPageMin = 1
  235. g_iPageMax = Int(iQuotaEntryCountTotal / ROWS_PER_PAGE )
  236. If ( (iQuotaEntryCountTotal MOD ROWS_PER_PAGE) >= 0 ) Then
  237. g_iPageMax = g_iPageMax + 1
  238. End If
  239. g_iPageCurrent = 1
  240. Call OTS_SetPagingRange(table, g_iPageMin, g_iPageMax, g_iPageCurrent)
  241. End If
  242. '
  243. ' Enable table multiselection
  244. Call OTS_SetTableMultiSelection(table, TRUE)
  245. '
  246. ' Sort the table
  247. Call OTS_SortTable(table, g_iSortCol, g_sSortSequence, SA_RESERVED)
  248. '
  249. ' Send table to the Response stream
  250. nReturnValue = OTS_ServeTable(table)
  251. If nReturnValue <> OTS_ERR_SUCCESS Then
  252. Call SA_ServeFailurePage(L_SERVETABLE_FAIL_ERRORMESSAGE)
  253. End If
  254. Response.Write("<input type=hidden name='"+PARENT_SELECTION+"' value='"+g_sParentSelection+"' >")
  255. '
  256. ' All done...
  257. OnServeAreaPage = TRUE
  258. End Function
  259. '---------------------------------------------------------------------
  260. ' Function: OnSearchNotify()
  261. '
  262. ' Synopsis: Search notification event handler. When one or more columns are
  263. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  264. ' this event in the following scenarios:
  265. '
  266. ' 1) The user presses the search Go button.
  267. ' 2) The user requests a table column sort
  268. ' 3) The user presses either the page next or page previous buttons
  269. '
  270. ' The oEventArg indicates the source of this notification event which can
  271. ' be either a search change event (scenario 1) or a post back event
  272. ' (scenarios 2 or 3)
  273. '
  274. ' Arguments: [in] oPageIn Page on which this event has been fired.
  275. ' [in] oEventArg Event argument for this event.
  276. ' [in] iColumnNo Column number of the column that was selected.
  277. ' [in] sValue Search value that the user typed into the search box.
  278. ' Returns: Always returns TRUE
  279. '
  280. '---------------------------------------------------------------------
  281. Public Function OnSearchNotify(ByRef oPageIn, _
  282. ByRef oEventArg, _
  283. ByVal iColumnNo, _
  284. ByVal sValue )
  285. OnSearchNotify = TRUE
  286. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify")
  287. '
  288. ' User pressed the search GO button
  289. '
  290. If SA_IsChangeEvent(oEventArg) Then
  291. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  292. g_bSearchChanged = TRUE
  293. g_iSearchCol = iColumnNo
  294. g_sSearchColValue = CStr(sValue)
  295. '
  296. ' User clicked a column sort, OR clicked either the page next or page prev button
  297. ElseIf SA_IsPostBackEvent(oEventArg) Then
  298. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  299. g_bSearchChanged = FALSE
  300. g_iSearchCol = iColumnNo
  301. g_sSearchColValue = CStr(sValue)
  302. '
  303. ' Unknown event source
  304. Else
  305. Call SA_TraceErrorOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  306. End IF
  307. End Function
  308. '---------------------------------------------------------------------
  309. ' Function: OnPagingNotify()
  310. '
  311. ' Synopsis: Paging notification event handler. This event is triggered in one of
  312. ' the following scenarios:
  313. '
  314. ' 1) The user presses either the page next or page previous buttons
  315. ' 2) The user presses the search Go button.
  316. ' 3) The user requests a table column sort
  317. '
  318. ' The oEventArg indicates the source of this notification event which can
  319. ' be either a paging change event (scenario 1) or a post back event
  320. ' (scenarios 2 or 3)
  321. '
  322. ' The iPageCurrent argument indicates which page the user has requested.
  323. ' This is an integer value between iPageMin and iPageMax.
  324. '
  325. ' Arguments: [in] oPageIn Page on which this event has been fired.
  326. ' [in] oEventArg Event argument for this event.
  327. ' [in] sPageAction Page navigation action which will be a string value
  328. ' of either: "next", or "prev"
  329. ' [in] iPageMin Minimum page number
  330. ' [in] iPageMax Maximum page number
  331. ' [in] iPageCurrent Current page
  332. '
  333. ' Returns: Always returns TRUE
  334. '
  335. '---------------------------------------------------------------------
  336. Public Function OnPagingNotify(ByRef oPageIn, _
  337. ByRef oEventArg, _
  338. ByVal sPageAction, _
  339. ByVal iPageMin, _
  340. ByVal iPageMax, _
  341. ByVal iPageCurrent )
  342. OnPagingNotify = TRUE
  343. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify")
  344. g_bPagingInitialized = TRUE
  345. g_iPageMin = iPageMin
  346. g_iPageMax = iPageMax
  347. g_iPageCurrent = iPageCurrent
  348. End Function
  349. '---------------------------------------------------------------------
  350. ' Function: OnSortNotify()
  351. '
  352. ' Synopsis: Sorting notification event handler. This event is triggered in one of
  353. ' the following scenarios:
  354. '
  355. ' 1) The user presses the search Go button.
  356. ' 2) The user presses either the page next or page previous buttons
  357. ' 3) The user requests a table column sort
  358. '
  359. ' The oEventArg indicates the source of this notification event which can
  360. ' be either a sorting change event (scenario 1) or a post back event
  361. ' (scenarios 2 or 3)
  362. '
  363. ' The sortCol argument indicated which column the user would like to sort
  364. ' and the sortSeq argument indicates the desired sort sequence which can
  365. ' be either ascending or descending.
  366. '
  367. ' Arguments: [in] oPageIn Page on which this event has been fired.
  368. ' [in] oEventArg Event argument for this event.
  369. ' [in] iSortCol Column number of the column that is to be sorted.
  370. ' [in] sSortSeq Sequence that the column is to be sorted. "A" for ascending,
  371. ' "D" for descending.
  372. '
  373. ' Returns: Always returns TRUE
  374. '
  375. '---------------------------------------------------------------------
  376. Public Function OnSortNotify(ByRef oPageIn, _
  377. ByRef oEventArg, _
  378. ByVal iSortCol, _
  379. ByVal sSortSeq )
  380. OnSortNotify = TRUE
  381. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify")
  382. g_iSortCol = iSortCol
  383. g_sSortSequence = sSortSeq
  384. End Function
  385. '---------------------------------------------------------------------
  386. ' Function name: AddItemsToTable
  387. ' Description: Called to add rows to the table
  388. ' Input Variables: Out: Table
  389. ' Out: iVolumeCount
  390. ' Out: iSelectedVolumeCount
  391. ' Output Variables: None
  392. ' Return Values: None
  393. ' Global Variables: In: g_(*)
  394. ' In: L_(*)
  395. '---------------------------------------------------------------------
  396. Private Function AddItemsToTable(ByRef Table, ByRef iQuotaEntryCount, ByRef iSelectedQuotaEntryCount)
  397. Call SA_TraceOut(SOURCE_FILE, "AddItemsToTable")
  398. On Error Resume Next
  399. Err.clear
  400. Dim strLogonUser ' Logon user - column 1
  401. Dim strQuotaStatus ' Quota Status - column 2
  402. Dim strQuotaUsed ' Disk used - column 3
  403. Dim strQuotaLimit ' Quota limit - column 4
  404. Dim strWarningLimit ' Warning limit - column 5
  405. Dim objQuotas ' Quotas object
  406. Dim objQuota ' Quota object
  407. ' initialize
  408. iQuotaEntryCount = 0
  409. iSelectedQuotaEntryCount = 0
  410. ' get the diskQuota object
  411. Set objQuotas = CreateObject("Microsoft.DiskQuota.1")
  412. objQuotas.Initialize F_strVolName &"\", 1
  413. objQuotas.UserNameResolution = 1 ' wait for user names
  414. If Err.Number <> 0 Then
  415. Set objQuotas = Nothing
  416. Call SA_ServeFailurePage(L_OBJECTNOTCREATED_ERRORMESSAGE)
  417. End If
  418. ' loop through the collection and display the quota entries
  419. For Each objQuota in objQuotas
  420. '
  421. ' Get the column values to variables first.
  422. ' Then display the quota entries
  423. ' get the Logon Name
  424. If objQuota.LogonName <> "" Then
  425. strLogonUser = objQuota.LogonName
  426. Else
  427. strLogonUser = L_INFORMATIONNOTFOUND_ERRORMESSAGE
  428. End If
  429. ' get the Status info. Initialize to OK first.
  430. strQuotaStatus = L_STATUS_OK_TEXT
  431. If objQuota.QuotaLimit <> -1 Then
  432. ' Some Limit is set. Compare disk used and disk limit
  433. If objQuota.QuotaUsed > objQuota.QuotaLimit Then
  434. strQuotaStatus = L_STATUS_ABOVE_LIMIT_TEXT
  435. ' else, status is initialized to OK
  436. End If
  437. Else
  438. ' "No Limit" is set on disk usage
  439. strQuotaStatus = L_NOLIMIT_TEXT
  440. End If
  441. ' the amount of disk space used
  442. strQuotaUsed = ConvertQuotaValueToUnits(objQuota.QuotaUsed)
  443. 'If disk limit is -1(No Limit) then assign "No limit"
  444. 'else read the limit in Text form
  445. If ( objQuota.QuotaLimit = -1 ) Then
  446. strQuotaLimit = L_NOLIMIT_TEXT
  447. Else
  448. strQuotaLimit = ConvertQuotaValueToUnits(objQuota.QuotaLimit)
  449. End If
  450. 'If warning limit is -1(No Limit) then assign "No limit"
  451. 'else read the limit in Text form
  452. If ( objQuota.QuotaThreshold = -1 ) Then
  453. strWarningLimit = L_NOLIMIT_TEXT
  454. Else
  455. strWarningLimit = ConvertQuotaValueToUnits(objQuota.QuotaThreshold)
  456. End If
  457. '
  458. ' All the column values are populated. Add to the OTS row
  459. ' depending on the search criteria
  460. '
  461. If ( Len( g_sSearchColValue ) <= 0 ) Then
  462. '
  463. ' Search criteria blank, select all rows
  464. '
  465. iQuotaEntryCount = iQuotaEntryCount + 1
  466. '
  467. ' Verify that the current entry part of the current page
  468. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  469. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  470. If nReturnValue <> OTS_ERR_SUCCESS Then
  471. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  472. End If
  473. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  474. End If
  475. Else
  476. '
  477. ' Check the Search criteria
  478. '
  479. Select Case (g_iSearchCol)
  480. Case COLUMN_LOGONNAME
  481. If ( InStr(1, strLogonUser, trim(g_sSearchColValue), 1) ) Then
  482. iQuotaEntryCount = iQuotaEntryCount + 1
  483. '
  484. ' Verify that the current entry is part of the current page
  485. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  486. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  487. If nReturnValue <> OTS_ERR_SUCCESS Then
  488. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  489. End If
  490. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  491. End If
  492. End If
  493. Case COLUMN_STATUS
  494. If ( InStr(1, strQuotaStatus, trim(g_sSearchColValue), 1) ) Then
  495. iQuotaEntryCount = iQuotaEntryCount + 1
  496. '
  497. ' Verify that the current entry is part of the current page
  498. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  499. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  500. If nReturnValue <> OTS_ERR_SUCCESS Then
  501. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  502. End If
  503. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  504. End If
  505. End If
  506. Case COLUMN_AMOUNTUSED
  507. If (UCase(Left(strQuotaUsed, Len(g_sSearchColValue) )) = UCase(g_sSearchColValue)) Then
  508. iQuotaEntryCount = iQuotaEntryCount + 1
  509. '
  510. ' Verify that the current entry is part of the current page
  511. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  512. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  513. If nReturnValue <> OTS_ERR_SUCCESS Then
  514. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  515. End If
  516. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  517. End If
  518. End If
  519. Case COLUMN_QUOTALIMIT
  520. If (UCase(Left(strQuotaLimit, Len(g_sSearchColValue) )) = UCase(g_sSearchColValue)) Then
  521. iQuotaEntryCount = iQuotaEntryCount + 1
  522. '
  523. ' Verify that the current entry is part of the current page
  524. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  525. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  526. If nReturnValue <> OTS_ERR_SUCCESS Then
  527. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  528. End If
  529. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  530. End If
  531. End If
  532. Case COLUMN_WARNINGLEVEL
  533. If (UCase(Left(strWarningLimit, Len(g_sSearchColValue) )) = UCase(g_sSearchColValue)) Then
  534. iQuotaEntryCount = iQuotaEntryCount + 1
  535. '
  536. ' Verify that the current entry is part of the current page
  537. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  538. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  539. If nReturnValue <> OTS_ERR_SUCCESS Then
  540. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  541. End If
  542. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  543. End If
  544. End If
  545. Case Else
  546. Call SA_TraceErrorOut(SOURCE_FILE, "Unrecognized search column: " + CStr(g_iSearchCol))
  547. iQuotaEntryCount = iQuotaEntryCount + 1
  548. '
  549. ' Verify that the current entry is part of the current page
  550. If ( IsItemOnPage( iQuotaEntryCount, g_iPageCurrent, ROWS_PER_PAGE) ) Then
  551. nReturnValue = OTS_AddTableRow( Table, Array( strLogonUser, strQuotaStatus, strQuotaUsed, strQuotaLimit, strWarningLimit ))
  552. If nReturnValue <> OTS_ERR_SUCCESS Then
  553. Call SA_ServeFailurePage(L_ADDROW_FAIL_ERRORMESSAGE)
  554. End If
  555. iSelectedQuotaEntryCount = iSelectedQuotaEntryCount + 1
  556. End If
  557. End Select ' Select Case (g_iSearchCol)
  558. End If ' If ( Len( g_sSearchColValue ) <= 0 ) Then
  559. Next ' quota entry
  560. ' clean up
  561. Set objQuota = Nothing
  562. Set objQuotas = Nothing
  563. End Function
  564. '---------------------------------------------------------------------
  565. ' Function name: IsItemOnPage
  566. ' Description: to verify if the current selection belongs to current page
  567. ' Input Variables: In: iCurrentItem
  568. ' In: iItemsPerPage
  569. ' In: iCurrentPage
  570. ' Output Variables: None
  571. ' Return Values: True , if current selection belongs to the page, Else False
  572. ' Global Variables: None
  573. '---------------------------------------------------------------------
  574. Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  575. Dim iLowerLimit
  576. Dim iUpperLimit
  577. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  578. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  579. If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  580. IsItemOnPage = TRUE
  581. Else
  582. IsItemOnPage = FALSE
  583. End If
  584. End Function
  585. '---------------------------------------------------------------------
  586. ' Function name: isUserRestricted
  587. ' Description: to check if given user is to be restricted
  588. ' Input Variables: In: objQuotas - the Quotas object
  589. ' In: sUserName - the user to be verified
  590. ' Output Variables: None
  591. ' Return Values: True - if given user is restricted
  592. ' False - user is NOT restricted
  593. ' Global Variables: None
  594. ' Functions Called: (i)isUserInBuiltIn, (ii)isUserInSpecialGroups
  595. '
  596. ' If user is restricted, the corresponding QuotaEntry is NOT displayed.
  597. '---------------------------------------------------------------------
  598. Function isUserRestricted(objQuotas, sUserName)
  599. On Error Resume Next
  600. Err.Clear
  601. Dim sUserSID ' SID of the user
  602. Dim blnBuiltInUser ' boolean to store if user is Built-In
  603. Dim blnSpecialUser ' boolean to store if user is "Special Group"
  604. If Len(Trim(sUserName)) = 0 Then
  605. ' empty user name. User is restricted
  606. isUserRestricted = True
  607. Exit Function
  608. End If
  609. ' get the SID of the given user
  610. sUserSID = objQuotas.TranslateLogonNameToSID(sUserName)
  611. If Err.number <> 0 OR Len(Trim(sUserSID)) = 0 Then
  612. ' error OR empty SID name. User is restricted
  613. isUserRestricted = True
  614. Err.Clear
  615. Exit Function
  616. End If
  617. ' is the user a Built-In ( say, BuiltIn\Administrators)
  618. blnBuiltInUser = isUserInBuiltIn(sUserSID)
  619. ' is user a Special Group (say, NT Authority\System)
  620. blnSpecialUser = isUserInSpecialGroups(sUserSID)
  621. If blnBuiltInUser OR blnSpecialUser Then
  622. ' user belongs to Built-In or Special Group. User is restricted
  623. isUserRestricted = True
  624. Else
  625. ' given user is NOT restricted
  626. isUserRestricted = False
  627. End If
  628. End Function
  629. '---------------------------------------------------------------------
  630. ' Function name: isUserInBuiltIn
  631. ' Description: to check if given user is one of Built-In Users,
  632. ' Built-In Global Groups, Built-In Local Groups
  633. ' Input Variables: In: sUserSID - the Security Identifier (SID) for the
  634. ' user to be verified
  635. ' Output Variables: None
  636. ' Return Values: True - if given SID is a "Built-In"
  637. ' False - user does NOT belong to "Built-In"
  638. ' Global Variables: None
  639. '
  640. ' The function compares the Relative Identifier (RID) of given SID with
  641. ' a set of "Built-In" RIDs. If a match is found, return True else False.
  642. '---------------------------------------------------------------------
  643. Function isUserInBuiltIn(sUserSID)
  644. Dim arrBuiltInID ' to store RID values to restrict
  645. Dim arrSID ' to store the split SID values
  646. Dim nBound ' upper bound of the array
  647. Dim nRIDToCompare ' the RID value to compare
  648. Dim i ' to loop
  649. ' build the list of Restricted RID values
  650. arrBuiltInID = Array("500","501","512","513","514","544","545","546","548","549","550","551","552")
  651. ' initialize the return value to False
  652. isUserInBuiltIn = FALSE
  653. ' split the SID value ( to get the RID value at the end of it)
  654. arrSID = Split(CStr(sUserSID),"-")
  655. nBound = UBound(arrSID)
  656. ' RID value is at the end of SID
  657. nRIDToCompare = arrSID(nBound)
  658. ' get the number of times to be looped
  659. nBound = UBound(arrBuiltInID)
  660. ' loop through the list of Restricted values
  661. For i = 0 To nBound
  662. If (CDbl(nRIDToCompare) = CDbl(arrBuiltInID(i)) ) Then
  663. ' the RID of given SID is present in the Restricted List
  664. isUserInBuiltIn = TRUE
  665. Exit For
  666. End If
  667. Next
  668. End Function
  669. '---------------------------------------------------------------------
  670. ' Function name: isUserInSpecialGroups
  671. ' Description: to check if given user is one of "Special Groups"
  672. ' Input Variables: In: sUserSID - the Security Identifier (SID) for the
  673. ' user to be verified
  674. ' Output Variables: None
  675. ' Return Values: True - if given SID is a "Special Group"
  676. ' False - user does NOT belong to "Special Group"
  677. ' Global Variables: None
  678. '
  679. ' The function compares the given SID with a set of "Special Group" SIDs.
  680. ' If a match is found, return True else False.
  681. '---------------------------------------------------------------------
  682. Function isUserInSpecialGroups(sUserSID)
  683. ' special SID values (Restrict these users)
  684. Const SID_CREATOR_OWNER = "S-1-3-0"
  685. Const SID_EVERYONE = "S-1-1-0"
  686. Const SID_NT_NETWORK = "S-1-5-2"
  687. Const SID_NT_INTERACTIVE = "S-1-5-4"
  688. Const SID_NT_SYSTEM = "S-1-5-18"
  689. Const SID_NT_AUTHENTICATED_USERS = "S-1-5-11"
  690. Dim arrSpecialGroups ' to store SID values to be restricted
  691. Dim nBound ' to store upper bound of the array
  692. Dim i ' to loop
  693. ' initialize return value to false
  694. isUserInSpecialGroups = FALSE
  695. ' build the list of Restricted SIDs
  696. arrSpecialGroups = Array(SID_CREATOR_OWNER, SID_EVERYONE, SID_NT_NETWORK, SID_NT_INTERACTIVE, SID_NT_SYSTEM, SID_NT_AUTHENTICATED_USERS)
  697. nBound = UBound(arrSpecialGroups)
  698. ' loop through the array
  699. For i = 0 To nBound
  700. If (LCase(sUserSID) = LCase(arrSpecialGroups(i))) Then
  701. ' the given SID is present in the Restricted List of SIDs
  702. isUserInSpecialGroups = TRUE
  703. Exit For
  704. End If
  705. Next
  706. End Function
  707. %>