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.

113 lines
2.9 KiB

  1. <%
  2. const constAccessAuthorized = 1
  3. const constAccessApproveNonStd = 10
  4. const constAccessAdministrator = 100
  5. const constApprovalTypeWebsiteAccess = 1
  6. Sub EmailDomainFromLogon(szEmail, szDomain)
  7. dim ich
  8. dim szLogon
  9. szLogon = Request.ServerVariables("LOGON_USER")
  10. szEmail = ""
  11. szDomain = ""
  12. if szLogon = "" then
  13. Exit Sub
  14. end if
  15. for ich = Len(szLogon) to 1 step -1
  16. if (Mid(szLogon, ich, 1) = "\") and ich < Len(szLogon) and ich > 1 then
  17. szDomain = Left(szLogon, ich - 1)
  18. szEmail = Right(szLogon, Len(szLogon) - ich)
  19. exit sub
  20. end if
  21. next
  22. End Sub
  23. Function FIsAuthenticated(wAccessLevel)
  24. dim szSQL, szEmail, szDomain
  25. dim objConn, objCmd
  26. dim fResult, dwResult
  27. if Session("Authenticated") = "Yes" And wAccessLevel = constAccessAuthorized then
  28. FIsAuthenticated = True
  29. exit function
  30. end if
  31. EmailDomainFromLogon szEmail, szDomain
  32. if szEmail = "" or szDomain = "" then
  33. FIsAuthenticated = False
  34. exit function
  35. end if
  36. fResult = False
  37. set objConn = Server.CreateObject("ADODB.CONNECTION")
  38. objConn.Open szConnectionAuthorization
  39. 'objConn.Open "Driver=SQL Server;Server=TKOffDWSql02;DATABASE=Authorization;uid=ocasqlrw;pwd=FT126USW"
  40. set objCmd = Server.CreateObject("ADODB.COMMAND")
  41. objCmd.ActiveConnection = objConn
  42. objCmd.CommandType = &H0004
  43. if wAccessLevel = constAccessAuthorized then
  44. objCmd.CommandText = "OcaCheckUserAccessApprovals"
  45. else
  46. objCmd.CommandText = "OcaCheckUserAccess"
  47. end if
  48. objCmd.Parameters.Append objCmd.CreateParameter ("RETURN_VALUE", 3, &H0004)
  49. objCmd.Parameters.Append objCmd.CreateParameter ("@User",200,&H0001,50,szEmail)
  50. objCmd.Parameters.Append objCmd.CreateParameter ("@Domain",200,&H0001,50,szDomain)
  51. objCmd.Parameters.Append objCmd.CreateParameter ("@Level",3,&H0001,,wAccessLevel)
  52. if wAccessLevel = constAccessAuthorized then
  53. objCmd.Parameters.Append objCmd.CreateParameter ("@ApprovalTypeID",3,&H0001,,constApprovalTypeWebsiteAccess )
  54. end if
  55. objCmd.Execute
  56. dwResult = CLng(objCmd.Parameters("RETURN_VALUE"))
  57. if dwResult = 1 then
  58. if wAccessLevel = constAccessAuthorized then
  59. Session("Authenticated") = "Yes"
  60. end if
  61. fResult = True
  62. end if
  63. set objCmd = nothing
  64. objConn.Close
  65. set objConn = nothing
  66. FIsAuthenticated = fResult
  67. End Function
  68. Sub CheckSiteAccess
  69. dim szScript, szQuery, i
  70. if FIsAuthenticated(constAccessAuthorized) then
  71. Exit Sub
  72. end if
  73. szScript = Request.ServerVariables("SCRIPT_NAME")
  74. For i=Len(szScript) to 1 step -1
  75. if (Mid(szScript, i, 1) = "/") then
  76. szScript = "http://" & Request.ServerVariables("SERVER_NAME") & "/" & Right(szScript, Len(szScript) - i)
  77. exit for
  78. end if
  79. next
  80. szQuery = CStr(Request.ServerVariables("QUERY_STRING"))
  81. if Len(szQuery) > 0 then
  82. Response.Redirect "Authentication.asp?Orig=" & szScript & "?" & Server.URLEncode(szQuery)
  83. else
  84. Response.Redirect "Authentication.asp?Orig=" & szScript
  85. end if
  86. End Sub
  87. %>