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.

501 lines
16 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. '-------------------------------------------------------------------------
  5. ' groups.asp: Group area page - lists all the Groups,and provides
  6. ' links for creating new groups,editing and deleting groups
  7. '
  8. ' Copyright (c) Microsoft Corporation. All rights reserved.
  9. '
  10. ' Date Description
  11. ' 15-Jan-2001 Creation date
  12. '-------------------------------------------------------------------------
  13. %>
  14. <!-- #include virtual="/admin/inc_framework.asp" -->
  15. <!-- #include virtual="/admin/ots_main.asp" -->
  16. <%
  17. '-------------------------------------------------------------------------
  18. ' Global Constants
  19. '-------------------------------------------------------------------------
  20. Const NAME_COLUMN = 0
  21. Const DESCRIPTION_COLUMN = 1
  22. Const GROUPS_PER_PAGE = 100
  23. '
  24. ' Name of this source file
  25. Const SOURCE_FILE = "Groups.asp"
  26. '
  27. ' Flag to toggle optional tracing output
  28. Const ENABLE_TRACING = TRUE
  29. '-------------------------------------------------------------------------
  30. ' Global Variables
  31. '-------------------------------------------------------------------------
  32. Dim g_bSearchChanged
  33. Dim g_iSearchCol
  34. Dim g_sSearchColValue
  35. Dim g_bPagingInitialized
  36. Dim g_bPageChangeRequested
  37. Dim g_sPageAction
  38. Dim g_iPageMin
  39. Dim g_iPageMax
  40. Dim g_iPageCurrent
  41. Dim g_bSortRequested
  42. Dim g_iSortCol
  43. Dim g_sSortSequence
  44. '-------------------------------------------------------------------------
  45. ' Local Variables
  46. '-------------------------------------------------------------------------
  47. Dim page
  48. DIM L_APPLIANCE_GROUPS
  49. DIM L_DESCRIPTION_HEADING
  50. DIM L_COLUMN_NAME
  51. DIM L_COLUMN_FULLNAME
  52. DIM L_TASKS_TEXT
  53. DIM L_NEW_TEXT
  54. DIM L_DELETE_TEXT
  55. DIM L_PROPERTIES_TEXT
  56. DIM L_NEW_ROLLOVERTEXT
  57. DIM L_DELETE_ROLLOVERTEXT
  58. DIM L_PROPERTIES_ROLLOVERTEXT
  59. 'error messages
  60. Dim L_FAILEDTOGETGROUPS_ERRORMESSAGE
  61. L_APPLIANCE_GROUPS = GetLocString("usermsg.dll", "&H4031001C", "")
  62. L_DESCRIPTION_HEADING = GetLocString("usermsg.dll", "&H4031001D", "")
  63. L_COLUMN_NAME = GetLocString("usermsg.dll", "&H4031001E", "")
  64. L_COLUMN_FULLNAME = GetLocString("usermsg.dll", "&H4031001F", "")
  65. L_TASKS_TEXT = GetLocString("usermsg.dll", "&H40310020", "")
  66. L_NEW_TEXT = GetLocString("usermsg.dll", "&H40310021", "")
  67. L_DELETE_TEXT = GetLocString("usermsg.dll", "&H40310022", "")
  68. L_PROPERTIES_TEXT = GetLocString("usermsg.dll", "&H40310023", "")
  69. L_NEW_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310024", "")
  70. L_DELETE_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310025", "")
  71. L_PROPERTIES_ROLLOVERTEXT = GetLocString("usermsg.dll", "&H40310026", "")
  72. 'error messages
  73. L_FAILEDTOGETGROUPS_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031002E", "")
  74. '
  75. ' Create Page
  76. Call SA_CreatePage( L_APPLIANCE_GROUPS, "", PT_AREA, page )
  77. '
  78. ' Show page
  79. Call SA_ShowPage( page )
  80. '---------------------------------------------------------------------
  81. ' Function name: OnInitPage
  82. ' Description: Called to signal first time processing for this page.
  83. ' Input Variables: PageIn and EventArg
  84. ' Output Variables: None
  85. ' Return Values: TRUE to indicate initialization was successful. FALSE to indicate
  86. ' errors. Returning FALSE will cause the page to be abandoned.
  87. ' Global Variables: None
  88. ' Called to signal first time processing for this page. Use this method
  89. ' to do first time initialization tasks.
  90. '---------------------------------------------------------------------
  91. Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  92. OnInitPage = TRUE
  93. If ( ENABLE_TRACING ) Then
  94. Call SA_TraceOut(SOURCE_FILE, "OnInitPage")
  95. End If
  96. g_bPagingInitialized = FALSE
  97. g_iPageCurrent = 1
  98. g_iSortCol = 0
  99. g_sSortSequence = "A"
  100. End Function
  101. '---------------------------------------------------------------------
  102. ' Function name: OnServeAreaPage
  103. ' Description: Called when the page needs to be served.
  104. ' Input Variables: PageIn, EventArg
  105. ' Output Variables: None
  106. ' Return Values: TRUE to indicate no problems occured. FALSE to indicate errors.
  107. ' Returning FALSE will cause the page to be abandoned.
  108. ' Global Variables: In:g_bPageChangeRequested,g_sPageAction,
  109. ' g_bSearchRequested,g_iSearchCol,g_sSearchColValue
  110. ' In:L_(*)-Localization Strings
  111. ' Called when the page needs to be served. Use this method to serve content.
  112. '---------------------------------------------------------------------
  113. Public Function OnServeAreaPage(ByRef PageIn, ByRef EventArg)
  114. If ( ENABLE_TRACING ) Then
  115. Call SA_TraceOut(SOURCE_FILE, "OnServeAreaPage")
  116. End If
  117. Dim tableGroup
  118. Dim colFlags
  119. Dim iGroupCount
  120. Dim nReturnValue
  121. Dim strFlag
  122. Dim strUrlBase
  123. strFlag="noval"
  124. ' Create the table
  125. '
  126. tableGroup = OTS_CreateTable("", L_DESCRIPTION_HEADING)
  127. '
  128. ' If the search criteria changed then we need to recompute the paging range
  129. If ( TRUE = g_bSearchChanged ) Then
  130. '
  131. ' Need to recalculate the paging range
  132. g_bPagingInitialized = FALSE
  133. '
  134. ' Restarting on page #1
  135. g_iPageCurrent = 1
  136. End If
  137. '
  138. ' Name column is searchable and is contains key to row
  139. colFlags = (OTS_COL_SORT OR OTS_COL_SEARCH OR OTS_COL_KEY)
  140. '
  141. ' Create the column and add it to the table
  142. nReturnValue= OTS_AddTableColumn(tableGroup, OTS_CreateColumnEx( L_COLUMN_NAME, "left", colFlags, 25 ))
  143. If nReturnValue <> gc_ERR_SUCCESS Then
  144. SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  145. OnServeAreaPage = false
  146. Exit Function
  147. End IF
  148. '
  149. ' Description is searchable
  150. colFlags = OTS_COL_SORT OR OTS_COL_SEARCH
  151. '
  152. ' Create the column and add it to the table
  153. nReturnValue=OTS_AddTableColumn(tableGroup, OTS_CreateColumnEx( L_COLUMN_FULLNAME, "left", colFlags, 50))
  154. If nReturnValue <> gc_ERR_SUCCESS Then
  155. SA_ServeFailurePage L_OTS_ADDCOLOUMNFAIL_ERRORMESSAGE
  156. OnServeAreaPage = false
  157. Exit Function
  158. End IF
  159. '
  160. ' Fetch the list of groups and add them to the table
  161. '
  162. Dim objContainer
  163. Dim objGroup
  164. '
  165. ' ADSI call to get the local computer object
  166. Set objContainer = GetObject("WinNT://" + GetComputerName() )
  167. '
  168. ' ADSI call to get the collection of local groups
  169. objContainer.Filter = Array("Group")
  170. iGroupCount = 0
  171. For Each objGroup in objContainer
  172. If ( Len( g_sSearchColValue ) <= 0 ) Then
  173. '
  174. ' Search criteria blank, select all rows
  175. '
  176. iGroupCount = iGroupCount + 1
  177. '
  178. ' Verify that the current group is part of the current page
  179. If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  180. Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  181. strFlag="yesval"
  182. End If
  183. Else
  184. '
  185. ' Check the Search criteria
  186. '
  187. Select Case (g_iSearchCol)
  188. Case NAME_COLUMN
  189. If ( InStr(1, objGroup.Name, g_sSearchColValue, 1) ) Then
  190. iGroupCount = iGroupCount + 1
  191. '
  192. ' Verify that the current group part of the current page
  193. If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  194. Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  195. strFlag="yesval"
  196. End If
  197. End If
  198. Case DESCRIPTION_COLUMN
  199. If ( InStr(1, objGroup.Description, g_sSearchColValue, 1) ) Then
  200. iGroupCount = iGroupCount + 1
  201. '
  202. ' Verify that the current group part of the current page
  203. If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  204. Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  205. strFlag="yesval"
  206. End If
  207. End If
  208. Case Else
  209. Call SA_TraceOut(SOURCE_FILE, "Unrecognized search column: " + CStr(g_iSearchCol))
  210. iGroupCount = iGroupCount + 1
  211. '
  212. ' Verify that the current group part of the current page
  213. If ( IsItemOnPage( iGroupCount, g_iPageCurrent, GROUPS_PER_PAGE) ) Then
  214. Call OTS_AddTableRow( tableGroup, Array(objGroup.Name, objGroup.Description))
  215. strFlag="yesval"
  216. End If
  217. End Select
  218. End If
  219. Next
  220. '
  221. ' Set Tasks section title
  222. Call OTS_SetTableTasksTitle(tableGroup, L_TASKS_TEXT)
  223. '
  224. ' Add the tasks associated with Group objects
  225. strUrlBase = "users/group_new.asp"
  226. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  227. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  228. Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_NEW_TEXT, _
  229. L_NEW_ROLLOVERTEXT, _
  230. strUrlBase,_
  231. OTS_PT_TABBED_PROPERTY, "OTS_TaskAlways") )
  232. strUrlBase = "users/group_delete.asp"
  233. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  234. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  235. Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_DELETE_TEXT, _
  236. L_DELETE_ROLLOVERTEXT, _
  237. strUrlBase,_
  238. OTS_PT_PROPERTY, "OTS_TaskAny") )
  239. strUrlBase = "users/group_prop.asp"
  240. call SA_MungeURL(strUrlBase,"Tab1",GetTab1())
  241. call SA_MungeURL(strUrlBase,"Tab2",GetTab2())
  242. Call OTS_AddTableTask( tableGroup, OTS_CreateTaskEx(L_PROPERTIES_TEXT, _
  243. L_PROPERTIES_ROLLOVERTEXT, _
  244. strUrlBase,_
  245. OTS_PT_TABBED_PROPERTY, "OTS_TaskOne") )
  246. Set objContainer = Nothing
  247. '
  248. ' Enable paging feature
  249. '
  250. Call OTS_EnablePaging(tableGroup, TRUE)
  251. '
  252. ' If paging range needs to be initialised then
  253. ' we need to figure out how many pages we are going to display
  254. If ( FALSE = g_bPagingInitialized ) Then
  255. g_iPageMin = 1
  256. g_iPageMax = Int(iGroupCount / GROUPS_PER_PAGE )
  257. If ( (iGroupCount MOD GROUPS_PER_PAGE) > 0 ) Then
  258. g_iPageMax = g_iPageMax + 1
  259. End If
  260. g_iPageCurrent = 1
  261. Call OTS_SetPagingRange(tableGroup, g_iPageMin, g_iPageMax, g_iPageCurrent)
  262. End If
  263. '
  264. ' Sort the table
  265. '
  266. Call OTS_SortTable(tableGroup, g_iSortCol, g_sSortSequence, SA_RESERVED)
  267. '
  268. ' Set MultiSelection enabled
  269. '
  270. Call OTS_SetTableMultiSelection(tableGroup,TRUE)
  271. '
  272. ' Send table to the response stream
  273. '
  274. Call OTS_ServeTable(tableGroup)
  275. '
  276. ' All done...
  277. OnServeAreaPage = TRUE
  278. End Function
  279. '---------------------------------------------------------------------
  280. ' Function name: OnSearchNotify()
  281. ' Description: Search notification event handler. When one or more columns are
  282. ' marked with the OTS_COL_SEARCH flag, the Web Framework fires
  283. ' this event
  284. ' Input Variables: PageIn,EventArg,sItem,sValue
  285. ' Output Variables: PageIn,EventArg,sItem,sValue
  286. ' Returns: Always returns TRUE
  287. '---------------------------------------------------------------------
  288. Public Function OnSearchNotify(ByRef PageIn, _
  289. ByRef EventArg, _
  290. ByRef sItem, _
  291. ByRef sValue )
  292. OnSearchNotify = TRUE
  293. '
  294. ' User pressed the search GO button
  295. '
  296. If SA_IsChangeEvent(EventArg) Then
  297. If ( ENABLE_TRACING ) Then
  298. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Change Event Fired")
  299. End If
  300. g_bSearchChanged = TRUE
  301. g_iSearchCol = Int(sItem)
  302. g_sSearchColValue = CStr(sValue)
  303. '
  304. ' User clicked a column sort, OR clicked either the page next or page prev button
  305. ElseIf SA_IsPostBackEvent(EventArg) Then
  306. If ( ENABLE_TRACING ) Then
  307. Call SA_TraceOut(SOURCE_FILE, "OnSearchNotify() Postback Event Fired")
  308. End If
  309. g_bSearchChanged = FALSE
  310. g_iSearchCol = Int(sItem)
  311. g_sSearchColValue = CStr(sValue)
  312. '
  313. ' Unknown event source
  314. Else
  315. If ( ENABLE_TRACING ) Then
  316. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  317. End If
  318. End IF
  319. End Function
  320. '---------------------------------------------------------------------
  321. ' Function: OnPagingNotify()
  322. ' Function name: OnPagingNotify()
  323. ' Description: Paging notification event handler.
  324. ' Input Variables: PageIn,EventArg,sPageAction,iPageMin,iPageMax,iPageCurrent
  325. ' Output Variables: PageIn,EventArg
  326. ' Return Values: Always returns TRUE
  327. ' Global Variables: G_*
  328. '---------------------------------------------------------------------
  329. Public Function OnPagingNotify(ByRef PageIn, _
  330. ByRef EventArg, _
  331. ByVal sPageAction, _
  332. ByVal iPageMin, _
  333. ByVal iPageMax, _
  334. ByVal iPageCurrent )
  335. OnPagingNotify = TRUE
  336. g_bPagingInitialized = TRUE
  337. '
  338. ' User pressed either page next or page previous
  339. '
  340. If SA_IsChangeEvent(EventArg) Then
  341. If ( ENABLE_TRACING ) Then
  342. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Change Event Fired")
  343. End If
  344. g_bPageChangeRequested = TRUE
  345. g_sPageAction = CStr(sPageAction)
  346. g_iPageMin = iPageMin
  347. g_iPageMax = iPageMax
  348. g_iPageCurrent = iPageCurrent
  349. '
  350. ' User clicked a column sort OR the search GO button
  351. ElseIf SA_IsPostBackEvent(EventArg) Then
  352. If ( ENABLE_TRACING ) Then
  353. Call SA_TraceOut(SOURCE_FILE, "OnPagingNotify() Postback Event Fired")
  354. End If
  355. g_bPageChangeRequested = FALSE
  356. g_sPageAction = CStr(sPageAction)
  357. g_iPageMin = iPageMin
  358. g_iPageMax = iPageMax
  359. g_iPageCurrent = iPageCurrent
  360. '
  361. ' Unknown event source
  362. Else
  363. If ( ENABLE_TRACING ) Then
  364. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnPagingNotify()")
  365. End If
  366. End IF
  367. End Function
  368. '---------------------------------------------------------------------
  369. ' Function: OnSortNotify()
  370. ' Function name: GetServices
  371. ' Description: Sorting notification event handler.
  372. ' Input Variables: PageIn,EventArg,sortCol,sortSeq
  373. ' Output Variables: PageIn,EventArg
  374. ' Return Values: Always returns TRUE
  375. ' Global Variables: G_*
  376. '---------------------------------------------------------------------
  377. Public Function OnSortNotify(ByRef PageIn, _
  378. ByRef EventArg, _
  379. ByVal sortCol, _
  380. ByVal sortSeq )
  381. OnSortNotify = TRUE
  382. '
  383. ' User pressed column sort
  384. '
  385. If SA_IsChangeEvent(EventArg) Then
  386. If ( ENABLE_TRACING ) Then
  387. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Change Event Fired")
  388. End If
  389. g_iSortCol = sortCol
  390. g_sSortSequence = sortSeq
  391. g_bSortRequested = TRUE
  392. '
  393. ' User presed the search GO button OR clicked either the page next or page prev button
  394. ElseIf SA_IsPostBackEvent(EventArg) Then
  395. If ( ENABLE_TRACING ) Then
  396. Call SA_TraceOut(SOURCE_FILE, "OnSortNotify() Postback Event Fired")
  397. End If
  398. g_iSortCol = sortCol
  399. g_sSortSequence = sortSeq
  400. g_bSortRequested = TRUE
  401. '
  402. ' Unknown event source
  403. Else
  404. If ( ENABLE_TRACING ) Then
  405. Call SA_TraceOut(SOURCE_FILE, "Unrecognized Event in OnSearchNotify()")
  406. End If
  407. End IF
  408. If ( ENABLE_TRACING ) Then
  409. Call SA_TraceOut(SOURCE_FILE, "Sort col: " + CStr(sortCol) + " sequence: " + sortSeq)
  410. End If
  411. End Function
  412. '---------------------------------------------------------------------
  413. ' Function: IsItemOnPage()
  414. ' Description: Verify that the current group part of the current page.
  415. ' Input Variables: iCurrentItem
  416. ' Output Variables: None
  417. ' Return Values: TRUE or FALSE
  418. ' Global Variables: None
  419. '---------------------------------------------------------------------
  420. Private Function IsItemOnPage(ByVal iCurrentItem, iCurrentPage, iItemsPerPage)
  421. Dim iLowerLimit
  422. Dim iUpperLimit
  423. iLowerLimit = ((iCurrentPage - 1) * iItemsPerPage )
  424. iUpperLimit = iLowerLimit + iItemsPerPage + 1
  425. If ( iCurrentItem > iLowerLimit AND iCurrentItem < iUpperLimit ) Then
  426. IsItemOnPage = TRUE
  427. Else
  428. IsItemOnPage = FALSE
  429. End If
  430. End Function
  431. %>