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.

473 lines
14 KiB

  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <%
  4. dim szEmail, szServerEmail, szServerDomain, szOrigURL, szReason
  5. dim fBadEmail, fBadCheck, fAgreeCheck, fBadReason, fLimited
  6. dim objConn, objCmd, dwResult
  7. Response.Buffer=false
  8. Response.CacheControl="no-cache"
  9. Response.AddHeader "Pragma", "no-cache"
  10. Response.Expires=-1
  11. %>
  12. <!-- #include file="util.asp"-->
  13. <!-- #include file="AccessUtil.asp"-->
  14. <!-- #include file="MailUtil.asp"-->
  15. <%
  16. Sub AddAuthenticationLevel(szEmail, szDomain, wAccessLevel)
  17. dim objConn, objRec, szSQL, dwUserID, dwUserAccessLevelID
  18. dim objCmd, res, dwResult
  19. dwUserID = 0
  20. 'Response.Write("Connection: " + szConnectionAuthorization + "<BR>")
  21. set objConn = Server.CreateObject("ADODB.CONNECTION")
  22. 'objConn.Open szConnectionAuthorization, OCA_RW_UID, OCA_RW_PWD
  23. objConn.Open szConnectionAuthorization
  24. set objCmd = Server.CreateObject("ADODB.COMMAND")
  25. objCmd.ActiveConnection = objConn
  26. objCmd.CommandType = &H0004
  27. objCmd.CommandText = "OcaAddUserAndLevel"
  28. objCmd.Parameters.Append objCmd.CreateParameter ("RETURN_VALUE", 3, &H0004)
  29. objCmd.Parameters.Append objCmd.CreateParameter ("@User",200,&H0001,50,szEmail)
  30. objCmd.Parameters.Append objCmd.CreateParameter ("@Domain",200,&H0001,50,szDomain)
  31. objCmd.Parameters.Append objCmd.CreateParameter ("@CurrTime",200,&H0001,50,CStr(Now()))
  32. objCmd.Parameters.Append objCmd.CreateParameter ("@Level",3,&H0001,,wAccessLevel)
  33. 'Response.Write("User: " & szEmail & " domain: " & szDomain & " access: " & wAccessLevel )
  34. objCmd.Execute
  35. dwResult = CLng(objCmd.Parameters("RETURN_VALUE"))
  36. set objCmd = nothing
  37. objConn.Close
  38. set objConn = nothing
  39. if dwResult = 0 then
  40. Response.Write "<html><body>Error #1 validating user information.: " & dwResult
  41. Response.End
  42. end if
  43. End Sub
  44. Function AddUserForApproval(ApprovalTypeID, szEmail, szDomain, szReason)
  45. dim objConn, objRec, szSQL, dwUserID, dwUserAccessLevelID
  46. dim objCmd, res, dwResult
  47. set objConn = Server.CreateObject("ADODB.CONNECTION")
  48. 'objConn.Open szConnectionAuthorization, OCA_RW_UID, OCA_RW_PWD
  49. objConn.Open szConnectionAuthorization
  50. set objCmd = Server.CreateObject("ADODB.COMMAND")
  51. objCmd.ActiveConnection = objConn
  52. objCmd.CommandType = &H0004
  53. objCmd.CommandText = "OcaAddUserForApproval"
  54. objCmd.Parameters.Append objCmd.CreateParameter ("RETURN_VALUE", 3, &H0004)
  55. objCmd.Parameters.Append objCmd.CreateParameter ("@ApprovalType",3,&H0001,,ApprovalTypeID)
  56. objCmd.Parameters.Append objCmd.CreateParameter ("@User",200,&H0001,50,szEmail)
  57. objCmd.Parameters.Append objCmd.CreateParameter ("@Domain",200,&H0001,50,szDomain)
  58. objCmd.Parameters.Append objCmd.CreateParameter ("@Reason",200,&H0001,255,szReason)
  59. objCmd.Execute
  60. dwResult = CLng(objCmd.Parameters("RETURN_VALUE"))
  61. set objCmd = nothing
  62. objConn.Close
  63. set objConn = nothing
  64. if dwResult = -1 then
  65. Response.Write "<html><body>Error #2 validating user information."
  66. Response.End
  67. end if
  68. AddUserForApproval = dwResult
  69. End Function
  70. Function FLimitedUser(szEmail, szDomain)
  71. Dim szEmailT, szDomainT
  72. FLimitedUser=False
  73. exit function
  74. szEmailT = CStr(szEmail)
  75. szDomainT = CStr(szDomain)
  76. if Len(szEmailT) = 0 or Len(szDomainT) = 0 then
  77. FLimitedUser = False
  78. exit function
  79. end if
  80. if (Len(szEmailT) >=3) then
  81. if Mid(szEmailT, 2, 1) = "-" then
  82. FLimitedUser = True
  83. Exit Function
  84. end if
  85. end if
  86. if StrComp(szDomainT, "redmond", vbTextCompare) <> 0 And StrComp(szDomainT, "ntdev", vbTextCompare) <> 0 And _
  87. StrComp(szDomainT, "northamerica", vbTextCompare) <> 0 then
  88. FLimitedUser = True
  89. exit function
  90. end if
  91. FLimitedUser = False
  92. End Function
  93. Sub DoRedirect
  94. if (szOrigURL <> "") then
  95. Response.Redirect szOrigURL
  96. end if
  97. Response.Redirect "../dbgportalv2.asp"
  98. Response.End
  99. End Sub
  100. Sub DoNoAccess
  101. Response.Write "<html><body>"
  102. Response.Write "Access to this website has been denied. If you have questions concerning this, please E-mail "
  103. Response.Write "<a href='mailto:dwappr'>dwappr</a>."
  104. Response.End
  105. End Sub
  106. Function EmailListFromAccessLevelID(AccessLevelID)
  107. dim objConn, objRec, szSQL, dwUserID, dwUserAccessLevelID
  108. dim fFirst, szEmail, cCount
  109. fFirst = True
  110. set objConn = Server.CreateObject("ADODB.CONNECTION")
  111. set objRec = Server.CreateObject("ADODB.RECORDSET")
  112. 'objConn.Open szConnectionAuthorization, OCA_RO_UID, OCA_RO_PWD
  113. objConn.Open szConnectionAuthorization
  114. objConn.CommandTimeout = 600
  115. szSQL = "SELECT UserAlias FROM OcaAuthorizedUsers INNER JOIN OcaUserAccessLevels ON OcaAuthorizedUsers.UserID = OcaUserAccessLevels.UserID WHERE AccessLevelID = " & AccessLevelID
  116. set objRec = objConn.Execute (szSQL)
  117. szEmail = ""
  118. cCount = 0
  119. if not objRec.EOF then
  120. do until objRec.EOF
  121. cCount = cCount + 1
  122. if cCount > 10 then
  123. Response.Write "Mail overflow error!"
  124. Response.End
  125. end if
  126. if Not fFirst then
  127. szEmail = szEmail & ","
  128. else
  129. fFirst = False
  130. end if
  131. szEmail = szEmail & objRec("UserAlias") & "@microsoft.com"
  132. objRec.MoveNext
  133. Loop
  134. end if
  135. objRec.Close
  136. set objRec = nothing
  137. objConn.Close
  138. set objConn = nothing
  139. EmailListFromAccessLevelID = szEmail
  140. End Function
  141. Sub FindReplace(szString, szFind, szReplace)
  142. dim iPos, cchFind, szResult, cchString
  143. cchFind = Len(szFind)
  144. Do While (true)
  145. iPos = Instr(szString, szFind)
  146. if iPos = 0 then
  147. exit sub
  148. end if
  149. cchString = Len(szString)
  150. if iPos = 1 then
  151. szResult = ""
  152. else
  153. szResult = Left(szString, iPos - 1)
  154. end if
  155. szResult = szResult & szReplace
  156. if (iPos + cchFind - 1) <> cchString then
  157. szResult = szResult & Right(szString, 1+(cchString - (iPos + cchFind)))
  158. end if
  159. szString = szResult
  160. loop
  161. End Sub
  162. Sub DoApproval
  163. Response.Write "<html><head><title>Website Access Request</title></head><body>"
  164. Response.Write "Your request for website access was previously submitted, but has not been approved yet. You will receive an E-mail when it is approved.<p>If it has been more than 24-hours and you have not heard from us, please E-mail "
  165. Response.Write "<a href='mailto:dwappr'>dwappr</a>."
  166. Response.End
  167. End Sub
  168. Sub SendApprovalMail(dwUserID, AccessLevelID, szEmail, szDomain, szReason)
  169. dim szBody, szTo
  170. Const ForReading = 1, ForWriting = 2, ForAppending = 3
  171. Dim fs, f, szFilename
  172. szFilename = Server.MapPath("\") & "\ApproverEmail.htm"
  173. Set fs = CreateObject("Scripting.FileSystemObject")
  174. Set f = fs.OpenTextFile(szFilename, ForReading,False,0)
  175. szBody = f.ReadAll
  176. f.Close
  177. set f=nothing
  178. set fs = nothing
  179. FindReplace szBody, "%domainalias%", szDomain & "\" & szEmail
  180. FindReplace szBody, "%approveurl%", "http://watson/UserLevels.asp?UserID=" & dwUserID
  181. FindReplace szBody, "%requestuser%", szEmail
  182. FindReplace szBody, "%reason%", szReason
  183. szTo = EmailListFromAccessLevelID(AccessLevelID)
  184. if Not FSendMail("[email protected]", szTo, "Request for Watson Access", szBody, 15) then
  185. Response.Write "<html><body>"
  186. Response.Write "An error has occured while processing your request. Please E-mail "
  187. Response.Write "<a href='mailto:dwappr'>dwappr</a>."
  188. Response.End
  189. end if
  190. Response.Write "<html><head><title>Website Access Request</title></head><body>"
  191. Response.Write "Your request for website access has been submitted and you will receive an E-mail when it is approved.<p>If you don't hear from us within 24-hours, please E-mail "
  192. Response.Write "<a href='mailto:dwappr'>dwappr</a>."
  193. Response.End
  194. End Sub
  195. Sub ProcessApproval(szEmail, szDomain, szReason)
  196. dim dwUserID
  197. dim szReasonLimited
  198. szReasonLimited = szReason
  199. if Len(szReasonLimited) > 255 then
  200. szReasonLimited = Left(szReasonLimited, 255)
  201. end if
  202. dwUserID = AddUserForApproval(constApprovalTypeWebsiteAccess, szEmail, szDomain, szReasonLimited)
  203. 'SendApprovalMail dwUserID, constAccessApproveNonStd, szEmail, szDomain, szReasonLimited
  204. End Sub
  205. szEmail = ""
  206. szReason = ""
  207. fBadReason = False
  208. fAgreeCheck = False
  209. szOrigURL = CStr(Request("Orig"))
  210. if CStr(Request.QueryString ) <> "" then
  211. szOrigURL = Request.QueryString
  212. end if
  213. //Response.Write "<BR> qyer: " & Request.QueryString
  214. //Response.Write "<BR> queyrstring: " & Request.QueryString( "OrigForm" )
  215. //Response.Write ("<BR><BR>SZOrigurl: " & szOrigURL )
  216. EmailDomainFromLogon szServerEmail, szServerDomain
  217. fLimited = FLimitedUser(szServerEmail, szServerDomain)
  218. set objConn = Server.CreateObject("ADODB.CONNECTION")
  219. 'objConn.Open szConnectionAuthorization, OCA_RO_UID, OCA_RO_PWD
  220. 'objConn.Open "Driver=SQL Server;Server=TKOffDWSql02;DATABASE=Authorization;uid=ocasqlrw;pwd=FT126USW"
  221. objConn.Open szConnectionAuthorization
  222. set objCmd = Server.CreateObject("ADODB.COMMAND")
  223. objCmd.ActiveConnection = objConn
  224. objCmd.CommandType = &H0004
  225. objCmd.CommandText = "OcaCheckUserAccessApprovals"
  226. objCmd.Parameters.Append objCmd.CreateParameter ("RETURN_VALUE", 3, &H0004)
  227. objCmd.Parameters.Append objCmd.CreateParameter ("@User",200,&H0001,50,szServerEmail)
  228. objCmd.Parameters.Append objCmd.CreateParameter ("@Domain",200,&H0001,50,szServerDomain)
  229. objCmd.Parameters.Append objCmd.CreateParameter ("@Level",3,&H0001,,constAccessAuthorized)
  230. objCmd.Parameters.Append objCmd.CreateParameter ("@ApprovalTypeID",3,&H0001,,constApprovalTypeWebsiteAccess )
  231. objCmd.Execute
  232. dwResult = CLng(objCmd.Parameters("RETURN_VALUE"))
  233. set objCmd = nothing
  234. objConn.Close
  235. set objConn = nothing
  236. if dwResult = 1 then
  237. Session("Authenticated") = "Yes"
  238. DoRedirect
  239. end if
  240. if dwResult = 2 then
  241. DoNoAccess
  242. end if
  243. if dwResult = 3 then
  244. DoApproval
  245. end if
  246. if (Request("Authentication") = "seen") then
  247. if Request.Form("chkAgree") <> "ON" then
  248. fBadCheck = True
  249. else
  250. fAgreeCheck = True
  251. end if
  252. szEmail = CStr(Request.Form("txtEmail"))
  253. if StrComp(szServerEmail, szEmail, vbTextCompare) <> 0 or szServerEmail = "" then
  254. fBadEmail = True
  255. end if
  256. if fLimited then
  257. szReason = CStr(Request.Form("txtReason"))
  258. if Len(szReason) = 0 then
  259. fBadReason = True
  260. end if
  261. end if
  262. if Not fBadEmail and Not fBadCheck and not fBadReason then
  263. if Not fLimited then
  264. Session("Authenticated") = "Yes"
  265. AddAuthenticationLevel szServerEmail, szServerDomain, constAccessAuthorized
  266. DoRedirect
  267. else
  268. AddAuthenticationLevel szServerEmail, szServerDomain, constAccessAuthorized
  269. ProcessApproval szServerEmail, szServerDomain, szReason
  270. end if
  271. end if
  272. end if
  273. %>
  274. <HTML><HEAD><TITLE>OCA Debug Portal Website Access</TITLE>
  275. <link rel="stylesheet" type="text/css" href="CallTree.css"/>
  276. <script language="javascript">
  277. function checkInput()
  278. {
  279. if (document.all.item("txtReason").value.length <= 255)
  280. Authentication_Form.submit();
  281. else
  282. {
  283. alert("The text in your reason is too long. Please limit your reason to 255 characters.");
  284. }
  285. }
  286. function checkReasonLength(inObj)
  287. {
  288. if (inObj.value.length <= 255)
  289. document.all.item("idReasonLength").style.display = "none";
  290. else
  291. document.all.item("idReasonLength").style.display = "";
  292. }
  293. </script>
  294. </HEAD>
  295. <BODY bgcolor=#eeeeee>
  296. <form name="Authentication_Form" href="Authentication.asp" method=post
  297. <% if fLimited then %>
  298. onSubmit="checkInput();return(false)"
  299. <% end if %>
  300. >
  301. <input type=hidden name="Authentication" value="seen">
  302. <input type=hidden name="Orig" value="<% =Server.HTMLEncode(szOrigURL) %>">
  303. <h1><font face="Verdana" style="font-size: 16pt">Private Customer Data</font></h1>
  304. <P align=left><B><FONT color=red face="Arial">Before entering this website, you must read and understand the
  305. <a href="http://watson.microsoft.com/dw/1033/dcp.asp">data collection policy</a></FONT></B></P>
  306. <H2><font style="font-size: 14pt; font-style: italic" face="Verdana">Summary</font></H2>
  307. <P><font face="Tahoma" size="2">The purpose of the Online Crash Analyses error reporting is to collect data and use it to
  308. improve Microsoft products. You cannot use OCA data for purposes other than
  309. finding and fixing bugs. </font>
  310. <ul>
  311. <LI><font face="Tahoma" size="2">If you discover information that identifies a customer, you may not
  312. contact that customer. (Except Microsoft employees and users who have
  313. explicitly agreed to be contacted.) </font>
  314. <LI><font face="Tahoma" size="2">If you want to work with an outside company to fix a problem you must talk
  315. to the <A href="mailto:blueteam">OCA</A> team first.</font></LI>
  316. </ul>
  317. <P><font face="Tahoma" size="2">Please understand that by accessing this data you are bound to the
  318. <a href="http://handbook/default.asp?contentpage=/f/guidelines13.asp">NDA</a> that you signed.</font></P>
  319. <% if fLimited then %>
  320. <H2><font style="font-size: 14pt; font-style: italic" face="Verdana">Request Access</font></H2>
  321. <p><font face="Tahoma" size="2">Please briefly describe why you need access to data
  322. on this website.&nbsp; You will be contacted by email when your request is
  323. approved.</font></P>
  324. <p style="margin-bottom: 0"><font face="Tahoma" size="2">I need to access Watson because:</font>
  325. </p>
  326. <textarea rows="3" name="txtReason" cols="47" onafterupdate="checkReasonLength(this)" onchange="checkReasonLength(this)" onkeyup="checkReasonLength(this)"><% =szReason %></textarea>
  327. <span id="idReasonLength" style="display:none"><font color=red>&lt;-- The text in your reason is too long. Please limit your reason to 255 characters.</font></span>
  328. <%
  329. if fBadReason then
  330. Response.Write "<font color=red>&lt;-- You need to specify a reason before submitting this request.</font>"
  331. end if
  332. %>
  333. </p>
  334. <% end if %>
  335. <P><font face="Tahoma"><font size="3">
  336. <INPUT type=checkbox name=chkAgree value="ON" <% if fAgreeCheck then %>checked<%end if %>></font><font size="2"> I have read and understand the <A
  337. href="http://watson.microsoft.com/dw/1033/dcp.asp">data collection
  338. policy</A>.</font></font>
  339. <%
  340. if fBadCheck then
  341. Response.Write "<font color=red>&lt;-- You need to read and understand the data collection policy.</font>"
  342. end if
  343. %>
  344. </P>
  345. <P><font face="Tahoma"><font size="2">Email alias:&nbsp; </font><font size="3">
  346. <INPUT name=txtEmail size="20" value="<% =szEmail %>"></font></font>
  347. <%
  348. if fBadEmail then
  349. Response.Write "<font color=red>&lt;-- Incorrect E-mail alias. For example, if your E-mail is [email protected], enter just <b><i>johndoe</i></b>.</font>"
  350. end if
  351. %>
  352. </P>
  353. <font face="Arial"><INPUT type=submit value=Submit>
  354. </font>
  355. </form>
  356. <font face="Tahoma" size="2">If you encounter problems when using this web page, please E-mail <a href="mailto:[email protected]">[email protected]</a>.</font>
  357. </BODY>
  358. </HTML>