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.

524 lines
17 KiB

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