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.

515 lines
14 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit
  3. Response.Buffer = true
  4. %>
  5. <!-- #include file="AuthorizedUtil.asp"-->
  6. <!-- #include file="MailUtil.asp"-->
  7. <%
  8. dim szSQL
  9. dim rgLevelID(), rgLevelDesc(), cElement, rgUserLevelDesc()
  10. dim objConn, objRec, objCmd
  11. dim UserID, AccessLevelID
  12. dim fFirst, dwUserID, iElement
  13. dim szReason, szApproverAlias, szApproverDomain, szDateApproved
  14. dim szHasApprovals, szSortType
  15. dim ApprovalTypeID
  16. Function GetUserIDFromLogon()
  17. dim szEmail, szDomain
  18. dim objConnT, objRecT, objCmdT
  19. dim dwResult
  20. EmailDomainFromLogon szEmail, szDomain
  21. set objConnT = Server.CreateObject("ADODB.CONNECTION")
  22. 'objConnT.Open szConnectionAuthorization, OCA_RO_UID, OCA_RO_PWD
  23. objConnT.Open szConnectionAuthorization
  24. set objCmdT = Server.CreateObject("ADODB.COMMAND")
  25. objCmdT.ActiveConnection = objConnT
  26. objCmdT.CommandType = &H0004
  27. objCmdT.CommandText = "OcaGetUserID"
  28. objCmdT.Parameters.Append objCmdT.CreateParameter ("RETURN_VALUE", 3, &H0004)
  29. objCmdT.Parameters.Append objCmdT.CreateParameter ("@User",200,&H0001,50,szEmail)
  30. objCmdT.Parameters.Append objCmdT.CreateParameter ("@Domain",200,&H0001,50,szDomain)
  31. objCmdT.Execute
  32. dwResult = CLng(objCmdT.Parameters("RETURN_VALUE"))
  33. set objCmdT = nothing
  34. objConnT.Close
  35. set objConnT = nothing
  36. GetUserIDFromLogon = dwResult
  37. End Function
  38. Function ArrayPosFromAccessLevelID(AccessLevelID, rgArray, cArray)
  39. dim iPos
  40. for iPos = 0 to cArray - 1
  41. if rgArray(iPos) = AccessLevelID then
  42. ArrayPosFromAccessLevelID = iPos
  43. exit function
  44. end if
  45. next
  46. ArrayPosFromAccessLevelID = -1
  47. End Function
  48. Sub ProcessApprovals(objConnIn, UserID)
  49. dim objRecApprovals
  50. dim szSQL
  51. dim fFirstRec, fFirstOverall
  52. set objRecApprovals = Server.CreateObject("ADODB.RECORDSET")
  53. szSQL = "select * from OcaApprovalList WHERE UserID = " & UserID & " ORDER BY dateapproved DESC, approvaltypeid ASC"
  54. set objRecApprovals = objConn.Execute (szSQL)
  55. if objRecApprovals.EOF then
  56. objRecApprovals.Close
  57. set objRecApprovals = nothing
  58. exit sub
  59. end if
  60. fFirstRec = True
  61. fFirstOverall = True
  62. do until objRecApprovals.EOF
  63. if IsNull(objRecApprovals("DateApproved")) then
  64. if FIsAuthenticated(CLng(objRecApprovals("ApproverAccessLevelID"))) or FIsAuthenticated(constAccessAdministrator) then
  65. if fFirstOverall then
  66. Response.Write "<br><br>"
  67. fFirstOverall = False
  68. end if
  69. if not fFirstRec then
  70. Response.Write "<hr>"
  71. end if
  72. %>
  73. <span style="color:red"><b><% =objRecApprovals("ApprovalDescription") %> request</b></span><br>
  74. <table><tr><td><b>Reason:</b></td><td><% =objRecApprovals("Reason") %></td></tr>
  75. <tr><td colspan=2>
  76. <a href="UserLevels.asp?UserID=<% =UserID %>&ApprovalTypeID=<% =objRecApprovals("ApprovalTypeID") %>&cmd=GrantAccess">Grant Access</a> (User will be notified via E-mail.)
  77. </td></tr>
  78. </table>
  79. <%
  80. fFirstRec = false
  81. end if
  82. else
  83. if fFirstOverall then
  84. Response.Write "<br><br>"
  85. fFirstOverall = False
  86. end if
  87. %>
  88. <i><% =objRecApprovals("ApprovalDescription") %> approved on <% =objRecApprovals("DateApproved") %> by <% =objRecApprovals("ApproverDomain") %>\<% =objRecApprovals("ApproverAlias") %></i><br>
  89. <%
  90. fFirstRec = false
  91. end if
  92. objRecApprovals.MoveNext
  93. Loop
  94. objRecApprovals.Close
  95. set objRecApprovals = nothing
  96. End Sub
  97. Sub DumpUnusedLevels(objConnIn, iElement, cElement, UserID)
  98. dim fFirstDesc
  99. fFirstDesc = True
  100. if szHasApprovals = "Yes" then
  101. ProcessApprovals objConnIn, UserID
  102. end if
  103. Response.Write "</td><td><td class=toprightleft>"
  104. for iElement = 0 to cElement - 1
  105. if rgUserLevelDesc(iElement) = "" then
  106. if fFirstDesc then
  107. Response.Write "<form action='UserLevels.asp' method=get style='margin:0pt'>"
  108. Response.Write "<input type=hidden name=cmd value=Add>"
  109. Response.Write "<input type=hidden name=UserID value=" & UserID & ">"
  110. Response.Write "<select name=AccessLevelID style='width:150px'>"
  111. fFirstDesc = false
  112. end if
  113. Response.Write "<option value=" & rgLevelID(iElement) & ">" & rgLevelDesc(iElement) & "</option>"
  114. end if
  115. next
  116. if not fFirstDesc then
  117. Response.Write "</select><input type=submit name=start value='Add'></form>"
  118. end if
  119. Response.Write "</td></tr>"
  120. End Sub
  121. %>
  122. <%
  123. dim szLogon, fValid, cUsers, UserIDParam
  124. dim fFirstDesc
  125. szSortType = CStr(Request("SortType"))
  126. if Len(CStr(Request("UserID"))) > 0 then
  127. UserIDParam = CLng(Request("UserID"))
  128. else
  129. UserIDParam = -1
  130. end if
  131. cUsers = 0
  132. szLogon = Request.ServerVariables("LOGON_USER")
  133. fValid = FIsAuthenticated(constAccessAdministrator)
  134. if szLogon = "REDMOND\solson" or szLogon = "REDMOND\derekmo" or szLogon = "REDMOND\erikt" or szLogon = "REDMOND\gabea" then
  135. fValid = True
  136. end if
  137. if Not fValid then
  138. Response.Write "You are not authorized to view this page . . .sorry<BR>"
  139. Response.End
  140. end if
  141. %>
  142. <html>
  143. <head><title>User Level Maintenance</title>
  144. <style>
  145. td { font-family: Verdana, sans-serif; color:black; font-size:10pt;
  146. padding-top:1px;
  147. padding-left:1px;
  148. padding-right:1px;
  149. font-size:8pt;
  150. }
  151. input { font-family: verdana; font-size: 8pt; margin: 0pt }
  152. select { font-family: verdana; font-size: 8pt; margin: 0pt }
  153. th { background-color:CFD5E5;
  154. font-size:11pt;
  155. padding-top:1px;
  156. padding-left:1px;
  157. padding-right:1px;
  158. }
  159. .no1 { font-family: Verdana, sans-serif; color:black;
  160. }
  161. .top {
  162. border-top: .5pt solid windowtext;
  163. }
  164. .left {
  165. border-left: .5pt solid windowtext;
  166. }
  167. .topleft {
  168. border-top: .5pt solid windowtext;
  169. border-left: .5pt solid windowtext;
  170. }
  171. .topright {
  172. border-top: .5pt solid windowtext;
  173. border-right: .5pt solid windowtext;
  174. }
  175. .toprightleft {
  176. border-top: .5pt solid windowtext;
  177. border-left: .5pt solid windowtext;
  178. border-right: .5pt solid windowtext;
  179. }
  180. .box {
  181. border-top: .5pt solid windowtext;
  182. border-bottom: .5pt solid windowtext;
  183. border-left: .5pt solid windowtext;
  184. border-right: .5pt solid windowtext;
  185. }
  186. </style>
  187. </head>
  188. <body style="font-family:Verdana, sans-serif;color:black; font-size:10pt">
  189. <%
  190. set objConn = Server.CreateObject("ADODB.CONNECTION")
  191. set objRec = Server.CreateObject("ADODB.RECORDSET")
  192. 'objConn.Open szConnectionAuthorization, OCA_RO_UID, OCA_RO_PWD
  193. 'objConn.Open "Driver=SQL Server;Server=TKOffDWSql02;DATABASE=Authorization;uid=ocasqlrw;pwd=FT126USW"
  194. objConn.Open szConnectionAuthorization
  195. objConn.CommandTimeout = 600
  196. szSQL = "select * from OcaAccessLevels"
  197. set objRec = objConn.Execute (szSQL)
  198. cElement = 0
  199. if not objRec.EOF then
  200. do until objRec.EOF
  201. cElement = cElement + 1
  202. Redim Preserve rgLevelID(cElement)
  203. Redim Preserve rgLevelDesc(cElement)
  204. rgLevelID(cElement - 1) = objRec("AccessLevelID")
  205. rgLevelDesc(cElement - 1) = objRec("AccessDescription")
  206. objRec.MoveNext
  207. Loop
  208. end if
  209. objRec.Close
  210. set objRec = nothing
  211. objConn.Close
  212. set objConn = nothing
  213. Redim rgUserLevelDesc(cElement)
  214. if Request("cmd") = "Add" or Request("cmd") = "Remove" then
  215. UserID = -1
  216. AccessLevelID = -1
  217. if Request("UserID") <> "" then
  218. UserID = CLng(Request("UserID"))
  219. end if
  220. if Request("AccessLevelID") <> "" then
  221. AccessLevelID = CLng(Request("AccessLevelID"))
  222. end if
  223. if UserID <> -1 and AccessLevelID <> -1 then
  224. set objConn = Server.CreateObject("ADODB.CONNECTION")
  225. 'objConn.Open szConnectionAuthorization, OCA_RW_UID, OCA_RW_PWD
  226. objConn.Open szConnectionAuthorization
  227. set objCmd = Server.CreateObject("ADODB.COMMAND")
  228. objCmd.ActiveConnection = objConn
  229. objCmd.CommandType = &H0004
  230. if Request("cmd") = "Remove" then
  231. objCmd.CommandText = "OcaRemoveUserLevel"
  232. else
  233. objCmd.CommandText = "OcaAddUserLevel"
  234. end if
  235. objCmd.Parameters.Append objCmd.CreateParameter ("@UserID",3,&H0001,,UserID)
  236. objCmd.Parameters.Append objCmd.CreateParameter ("@Level",3,&H0001,,AccessLevelID)
  237. objCmd.Execute
  238. set objCmd = nothing
  239. objConn.Close
  240. set objConn = nothing
  241. end if
  242. Response.Redirect "UserLevels.asp"
  243. end if
  244. if Request("cmd") = "GrantAccess" then
  245. UserID = -1
  246. ApprovalTypeID = -1
  247. if Request("UserID") <> "" then
  248. UserID = CLng(Request("UserID"))
  249. end if
  250. if Request("ApprovalTypeID") <> "" then
  251. ApprovalTypeID = CLng(Request("ApprovalTypeID"))
  252. end if
  253. if UserID <> -1 and ApprovalTypeID <> -1 then
  254. dim szServerEmail, szServerDomain, szToAlias, szBody
  255. dim ApproverUserID
  256. ApproverUserID = GetUserIDFromLogon()
  257. EmailDomainFromLogon szServerEmail, szServerDomain
  258. set objConn = Server.CreateObject("ADODB.CONNECTION")
  259. 'objConn.Open szConnectionAuthorization, OCA_RW_UID, OCA_RW_PWD
  260. objConn.Open szConnectionAuthorization
  261. set objCmd = Server.CreateObject("ADODB.COMMAND")
  262. objCmd.ActiveConnection = objConn
  263. objCmd.CommandType = &H0004
  264. objCmd.CommandText = "OcaApproveUser"
  265. objCmd.Parameters.Append objCmd.CreateParameter ("@UserID",3,&H0001,,UserID)
  266. objCmd.Parameters.Append objCmd.CreateParameter ("@ApprovalTypeID",3,&H0001,,ApprovalTypeID)
  267. objCmd.Parameters.Append objCmd.CreateParameter ("@ApproverUserID",3,&H0001,,ApproverUserID)
  268. objCmd.Parameters.Append objCmd.CreateParameter ("@DateApproved",200,&H0001,50,CStr(Now()))
  269. objCmd.Execute
  270. set objCmd = nothing
  271. set objRec = Server.CreateObject("ADODB.RECORDSET")
  272. szSQL = "SELECT UserAlias FROM OcaAuthorizedUsers WHERE UserID = " & UserID
  273. set objRec = objConn.Execute (szSQL)
  274. if not objRec.EOF then
  275. szToAlias = CStr(objRec("UserAlias")) & "@microsoft.com"
  276. else
  277. szToAlias = ""
  278. end if
  279. objRec.Close
  280. set objRec = nothing
  281. objConn.Close
  282. set objConn = nothing
  283. if szToAlias <> "" then
  284. Const ForReading = 1, ForWriting = 2, ForAppending = 3
  285. Dim fs, f, szFilename
  286. 'szFilename = Server.MapPath("\") & "\privacy\RequesterEmail.htm"
  287. 'Set fs = CreateObject("Scripting.FileSystemObject")
  288. 'Set f = fs.OpenTextFile(szFilename, ForReading,False,0)
  289. 'szBody = f.ReadAll
  290. szBody=""
  291. 'f.Close
  292. 'set f=nothing
  293. 'set fs = nothing
  294. 'if Not FSendMail("[email protected]", szToAlias, "OCA Debug Portal access granted", szBody, 10) then
  295. 'Response.Write "<html><body>"
  296. 'Response.Write "An error has occured while processing your request."
  297. 'Response.End
  298. 'end if
  299. end if
  300. end if
  301. Response.Redirect "UserLevels.asp"
  302. end if
  303. %>
  304. <center><form method=get action="UserLevels.asp"><b>Sort users by:</b>
  305. &nbsp;<input type=radio name="SortType" value="ByUserAlias"
  306. <% if szSortType<>"ByUserID" and szSortType<>"ByDateSigned" then %> checked <% end if %>
  307. >User alias
  308. &nbsp;<input type=radio name="SortType" value="ByUserID"
  309. <% if szSortType="ByUserID" then %> checked <% end if %>
  310. >First site access date
  311. &nbsp;<input type=radio name="SortType" value="ByDateSigned"
  312. <% if szSortType="ByDateSigned" then %> checked <% end if %>
  313. >Date signed DCP
  314. &nbsp;<input type=submit name="SortText" value="Change Sort">
  315. </form>
  316. </center>
  317. <table border=0 cellpadding=0 cellspacing=0 style="font-family:Verdana">
  318. <tr >
  319. <th class=topleft>Logon Domain/Alias<th class=topleft>Date DCP Signed<th class=toprightleft width=50%>User Level<td width=25>&nbsp;<th class=toprightleft>Actions
  320. <%
  321. set objConn = Server.CreateObject("ADODB.CONNECTION")
  322. set objRec = Server.CreateObject("ADODB.RECORDSET")
  323. 'objConn.Open szConnectionAuthorization, OCA_RO_UID, OCA_RO_PWD
  324. 'objConn.Open "Driver=SQL Server;Server=TKOffDWSql02;DATABASE=Authorization;uid=ocasqlrw;pwd=FT126USW"
  325. objConn.Open szConnectionAuthorization
  326. szSQL = "SELECT * FROM OcaUserList "
  327. if UserIDParam <> -1 then
  328. szSQL = szSQL & " WHERE UserID = " & UserIDParam
  329. end if
  330. if szSortType="ByUserID" then
  331. szSQL = szSQL & " ORDER BY NeedsApproval DESC, UserID ASC, AccessLevelID ASC"
  332. elseif szSortType="ByDateSigned" then
  333. szSQL = szSQL & " ORDER BY NeedsApproval DESC, DateSignedDCP ASC, AccessLevelID ASC"
  334. else
  335. szSQL = szSQL & " ORDER BY NeedsApproval DESC, UserAlias ASC, AccessLevelID ASC"
  336. end if
  337. set objRec = objConn.Execute (szSQL)
  338. if not objRec.EOF then
  339. fFirst = True
  340. do until objRec.EOF
  341. if Not fFirst then
  342. if CLng(objRec("UserID")) <> dwUserID then
  343. DumpUnusedLevels objConn,iElement, cElement, dwUserID
  344. fFirst = True
  345. else
  346. Response.Write ", " & objRec("AccessDescription") & " (<a href='UserLevels.asp?cmd=Remove&UserID=" & objRec("UserID") & "&AccessLevelID=" & objRec("AccessLevelID") & "'>Remove</a>)"
  347. rgUserLevelDesc(ArrayPosFromAccessLevelID(CLng(objRec("AccessLevelID")), rgLevelID, cElement)) = "Seen"
  348. end if
  349. end if
  350. if fFirst then
  351. for iElement = 0 to cElement - 1
  352. rgUserLevelDesc(iElement) = ""
  353. next
  354. cUsers = cUsers + 1
  355. rgUserLevelDesc(ArrayPosFromAccessLevelID(CLng(objRec("AccessLevelID")), rgLevelID, cElement)) = "Seen"
  356. Response.Write "<tr>"
  357. Response.Write "<td class=topleft>" & objRec("UserDomain") & "\" & objRec("UserAlias") & "</td>"
  358. Response.Write "<td class=topleft>" & objRec("DateSignedDCP") & "</td>"
  359. Response.Write "<td class=toprightleft>" & objRec("AccessDescription") & " (<a href='UserLevels.asp?cmd=Remove&UserID=" & objRec("UserID") & "&AccessLevelID=" & objRec("AccessLevelID") & "'>Remove</a>)"
  360. dwUserID = CLng(objRec("UserID"))
  361. szHasApprovals = objRec("HasApprovals")
  362. fFirst = False
  363. end if
  364. objRec.MoveNext
  365. Loop
  366. DumpUnusedLevels objConn,iElement, cElement, dwUserID
  367. Response.Write "<tr><td colspan=3 class=top>&nbsp;</td><td>&nbsp;</td><td class=top>&nbsp;</td></tr>"
  368. end if
  369. objRec.Close
  370. set objRec = nothing
  371. objConn.Close
  372. set objConn = nothing
  373. %>
  374. </table>
  375. <br>
  376. <% =cUsers %> users
  377. <p><b>Notes:</b></p>
  378. Adding the "No Access" level will prevent users from using the website. It takes precedence over all other levels. They will be denied access and directed to E-mail dwcore with questions.<br>
  379. Removing the "Authorized" level will cause the user to see the authorization sign-in page again.