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.

445 lines
16 KiB

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certrqxt.asp - (CERT)srv web - (R)e(Q)uest, e(XT)ernally created
  3. ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <%
  7. Dim sBrowserDependentLineBreak
  8. If "Text"<>sBrowser Then
  9. sBrowserDependentLineBreak="<BR>"
  10. Else
  11. sBrowserDependentLineBreak=""
  12. End If
  13. %>
  14. <HTML>
  15. <Head>
  16. <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  17. <Title>Microsoft Certificate Services</Title>
  18. </Head>
  19. <Body BgColor=#FFFFFF Link=#0000FF VLink=#0000FF ALink=#0000FF OnLoad="postLoad();"><Font ID=locPageFont Face="Arial">
  20. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  21. <TR>
  22. <TD><Font Color=#FFFFFF><LocID ID=locMSCertSrv><Font Face="Arial" Size=-1><B><I>Microsoft</I></B> Certificate Services &nbsp;--&nbsp; <%=sServerDisplayName%> &nbsp;</Font></LocID></Font></TD>
  23. <TD ID=locHomeAlign Align=Right><A Href="/certsrv"><Font Color=#FFFFFF><LocID ID=locHomeLink><Font Face="Arial" Size=-1><B>Home</B></Font></LocID></Font></A></TD>
  24. </TR>
  25. </Table>
  26. <Form Name=UIForm OnSubmit="goNext();return false;" Action="certlynx.asp" Method=Post>
  27. <Input Type=Hidden Name=SourcePage Value="certrqxt">
  28. <P><LocID ID=locPageTitle> <B> Submit a Certificate Request or Renewal Request</B></LocID>
  29. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  30. <%If "IE"=sBrowser Then%>
  31. <Span ID=spnFixTxt Style="display:none">
  32. <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000"><TR><TD><LocID ID=locBlankError>
  33. <I>The request field may not be left blank.</I> Please paste a request in the field and try again.
  34. </TD></LocID></TR></Table>
  35. </Span>
  36. <%End If%>
  37. <P><LocID ID=locInstructions>
  38. To submit a saved request to the CA, paste a base-64-encoded CMC or PKCS #10
  39. certificate request or PKCS #7 renewal request generated by an
  40. external source (such as a Web server) in the Saved Request box.</LocID>
  41. </P>
  42. <Table Border=0 CellSpacing=0 CellPadding=0>
  43. <TR> <!-- establish column widths. -->
  44. <TD><Img Src="certspc.gif" Alt="" Height=1 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  45. <TD RowSpan=59><Img Src="certspc.gif" Alt="" Height=1 Width=4></TD> <!-- label spacing column -->
  46. <TD></TD> <!-- field column -->
  47. </TR>
  48. <TR>
  49. <TD ColSpan=3><Font Face="Arial" Size=-1><Label For=locTaRequest><LocID ID=locSavedReqHead><B>Saved Request:</B></LocID></Label></Font></TD>
  50. </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  51. </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD></TR>
  52. <TR>
  53. <TD Align=Left><Span ID=spnPasteLabel><LocID ID=SavedReqLabel><Font Face="Arial" Size=-1>Base-64-encoded
  54. <%=sBrowserDependentLineBreak%> certificate request
  55. <%=sBrowserDependentLineBreak%> (CMC or
  56. <%=sBrowserDependentLineBreak%> PKCS&nbsp;#10 or
  57. <%=sBrowserDependentLineBreak%> PKCS&nbsp;#7):</Font></LocID></Span></TD>
  58. <TD><TextArea ID=locTaRequest Rows=6 Cols=40 Name=taRequest Wrap=Off></TextArea></TD>
  59. </TR><TR><TD ColSpan=3 Height=3></TD>
  60. </TR><TR><TD></TD>
  61. <TD><%If "IE"=sBrowser Then%>
  62. <LocID ID=locBrowse><Font Face="Arial" Size=-1><Span tabindex=0 Style="cursor:hand; color:#0000FF; text-decoration:underline;"
  63. OnContextMenu="return false;"
  64. OnKeyDown="if (13==event.keyCode) {BeginRead();blur();return false;} else if (9==event.keyCode) {return true;};return false;"
  65. OnClick="BeginRead();blur();return false;"
  66. OnMouseOver="window.status=L_BrowseLink_Message;return true;"
  67. OnMouseOut="window.status='';return true;">Browse for a file to insert</Span>.
  68. </Font></LocID>
  69. <Span ID=spRead Style="display:none">
  70. <Table Border=0 CellSpacing=0 CellPadding=0>
  71. <TR><TD Height=5></TD>
  72. <TR>
  73. <TD Width=6></TD>
  74. <TD Width=3 BgColor=#008080></TD>
  75. <TD Width=4></TD>
  76. <TD>
  77. <LocID ID=locFileNameLabel>Full path name:</LocID> <Input ID=locFlRequest Type=File Size=40 Name=flRequest><BR>
  78. <Input ID=locBtnRead Type=Button Value="Read!" onClick="FinishRead();blur();" Style="font-weight:bold">
  79. <Input ID=locBtnCancel Type=Button Value="Cancel" onClick="spRead.style.display='none';blur();">
  80. </TD>
  81. </TR>
  82. </Table>
  83. </Span>
  84. <%End If%></TD>
  85. </TR>
  86. <%If "Enterprise"=sServerType Then%>
  87. <TR>
  88. <TD ColSpan=3><LocID ID=locCertTmplFont><Font Face="Arial" Size=-1><%If "Text"=sBrowser Then%><P><%Else%><BR><%End If%><Label For=lbCertTemplateID><LocID ID=locTemplateHead><B>Certificate Template:</B></LocID></Label></Font></LocID></TD>
  89. </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  90. </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD>
  91. </TR><TR><TD></TD>
  92. <TD><Select Name=lbCertTemplate ID=lbCertTemplateID>
  93. <%
  94. Dim nWriteTemplateResult
  95. nWriteTemplateResult=WriteTemplateList()
  96. %>
  97. </Select></TD>
  98. </TR>
  99. <%End If%>
  100. <TR>
  101. <TD ColSpan=3><LocID ID=locAttrFont><Font Face="Arial" Size=-1><%If "Text"=sBrowser Then%><P><%Else%><BR><%End If%><Label For=locTaAttrib><LocID ID=locAttribHead><B>Additional Attributes:</B></LocID></Label></Font></LocID></TD>
  102. </TR><TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD>
  103. </TR><TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=6 Width=1></TD>
  104. </TR>
  105. <TR>
  106. <TD Align=Right><LocID ID=locAttribLabel><Font Face="Arial" Size=-1>Attributes:</Font></LocID></TD>
  107. <TD><TextArea ID=locTaAttrib Name=taAttrib Wrap=Off Rows=2 Cols=30></TextArea></TD>
  108. </TR>
  109. <%If "StandAlone"<>sServerType And 0<>nWriteTemplateResult Then%>
  110. <!-- submit button removed if there was an error getting the templates -->
  111. <%Else%>
  112. <TR><TD ColSpan=3><Font Size=-1><BR></Font></TD></TR>
  113. <TR><TD ColSpan=3 BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR>
  114. <TR><TD ColSpan=3><Img Src="certspc.gif" Alt="" Height=3 Width=1></TD></TR>
  115. <TR><TD><TD Align=Right><LocID ID=locSubmitAlign>
  116. <Input Type=Submit ID=btnSubmit Value="Submit &gt;" <%If "IE"=sBrowser Then%> Style="width:.75in"<%End If%>>
  117. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  118. </LocID></TD></TR>
  119. <TR><TD ColSpan=3 Height=20></TD></TR>
  120. <%End If%>
  121. </Table>
  122. <P>
  123. <!-- Green HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#008080><Img Src="certspc.gif" Alt="" Height=2 Width=1></TD></TR></Table>
  124. <!-- White HR --><Table Border=0 CellSpacing=0 CellPadding=0 Width=100%><TR><TD BgColor=#FFFFFF><Img Src="certspc.gif" Alt="" Height=5 Width=1></TD></TR></Table>
  125. </Form>
  126. </Font>
  127. <!-- ############################################################ -->
  128. <!-- End of standard text. Scripts follow -->
  129. <%bIncludeXEnroll=False%>
  130. <%bIncludeGetCspList=False%>
  131. <%bIncludeTemplateCode=True%>
  132. <!-- #include FILE=certsgcl.inc -->
  133. <!-- This form we fill in and submit 'by hand'-->
  134. <Form Name=SubmittedData Action="certfnsh.asp" Method=Post>
  135. <Input Type=Hidden Name=Mode> <!-- used in request ('newreq'|'chkpnd') -->
  136. <Input Type=Hidden Name=CertRequest> <!-- used in request -->
  137. <Input Type=Hidden Name=CertAttrib> <!-- used in request -->
  138. <Input Type=Hidden Name=FriendlyType> <!-- used on pending -->
  139. <Input Type=Hidden Name=ThumbPrint> <!-- used on pending -->
  140. <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  141. <Input Type=Hidden Name=SaveCert> <!-- used on install ('no'|'yes')-->
  142. </FORM>
  143. <Script Language="JavaScript">
  144. //----------------------------------------------------------------
  145. // Strings to be localized
  146. <%If "IE"=sBrowser Then%>
  147. ;
  148. var L_BrowseLink_Message="Browse for a file to insert";
  149. var L_ReadProhibited_ErrorMessage="Your web browser security settings prohibit this page from accessing your disk.\nEither paste the data into this page manually, or add this page to your browser's list of trusted sites.";
  150. var L_Unexpected_ErrorMessage="\"An unexpected error occurred while trying to read the file.\\n\\nError: \"+nResult";
  151. var L_FileNotFound_ErrorMessage="The file you specified was not found or the drive you specified\nwas not ready. Please enter a valid file name.";
  152. var L_NoName_ErrorMessage="Please enter a file name.";
  153. <%End If%>
  154. <%If "StandAlone"<>sServerType Then%>
  155. ;
  156. var L_TemplateLoadErrNoneFound_ErrorMessage="No certificate templates could be found. You do not have permission to request a certificate from this CA, or an error occurred while accessing the Active Directory.";
  157. var L_TemplateLoadErrUnexpected_ErrorMessage="\"An unexpected error (\"+sErrorNumber+\") occurred while getting the certificate template list.\"";
  158. <%End If%>
  159. ;
  160. var L_NoBlank_ErrorMessage="The request field may not be left blank.\n Please paste a request in the field and try again.";
  161. var L_SavedReqCert_Text="Saved-Request Certificate";
  162. //================================================================
  163. // INITIALIZATION ROUTINES
  164. //----------------------------------------------------------------
  165. // This contains the functions we want executed immediately after load completes
  166. function postLoad() {
  167. <%If "StandAlone"<>sServerType And 0<>nWriteTemplateResult Then%>
  168. handleLoadError(<%=nWriteTemplateResult%>, L_TemplateLoadErrNoneFound_ErrorMessage, L_TemplateLoadErrUnexpected_ErrorMessage);
  169. <%End If%>
  170. }
  171. <%If "StandAlone"<>sServerType Then%>
  172. //----------------------------------------------------------------
  173. // handle errors from GetTemplateList()
  174. function handleLoadError(nResult, sNoneFound, sUnexpected) {
  175. if (-1==nResult) {
  176. alert(sNoneFound);
  177. } else {
  178. var sErrorNumber="0x"+toHex(nResult);
  179. alert(eval(sUnexpected));
  180. }
  181. //document.UIForm.btnSubmit.disabled=true;
  182. }
  183. <%End If%>
  184. <%If "IE"=sBrowser Then%>
  185. //================================================================
  186. // FILE READ ROUTINES
  187. //----------------------------------------------------------------
  188. // IE SPECIFIC:
  189. // make sure that we have permision to do a read, then show
  190. // the file name box
  191. function BeginRead() {
  192. if (true==TestRead()) {
  193. spRead.style.display='';
  194. document.UIForm.flRequest.focus()
  195. } else {
  196. alert(L_ReadProhibited_ErrorMessage);
  197. }
  198. }
  199. //----------------------------------------------------------------
  200. // IE SPECIFIC:
  201. function FinishRead() {
  202. spnFixTxt.style.display='none';
  203. if (""==document.UIForm.flRequest.value) {
  204. handleReadError(5);
  205. return;
  206. }
  207. var nResult=GetFileData(); // use VBScript to read the file, since it can handle errors
  208. if (0!=nResult) {
  209. handleReadError(nResult);
  210. return;
  211. }
  212. spRead.style.display='none';
  213. document.UIForm.btnSubmit.focus()
  214. }
  215. //----------------------------------------------------------------
  216. // IE SPECIFIC:
  217. function handleReadError(nResult) {
  218. var sMessage;
  219. var elemFocusMe=null;
  220. if (429==nResult) {
  221. sMessage=L_ReadProhibited_ErrorMessage;
  222. elemFocusMe=document.UIForm.flRequest;
  223. } else if (53==nResult || 76==nResult || 71==nResult) {
  224. sMessage=L_FileNotFound_ErrorMessage;
  225. elemFocusMe=document.UIForm.flRequest;
  226. } else if (5==nResult) {
  227. sMessage=L_NoName_ErrorMessage;
  228. elemFocusMe=document.UIForm.flRequest;
  229. } else {
  230. sMessage=eval(L_Unexpected_ErrorMessage);
  231. }
  232. // Show the error message
  233. alert(sMessage);
  234. // place focus on offending control
  235. if (null!=elemFocusMe) {
  236. elemFocusMe.focus();
  237. }
  238. }
  239. <%End If%>
  240. //================================================================
  241. // SUBMIT ROUTINES
  242. //----------------------------------------------------------------
  243. // determine what to do when the submit button is pressed
  244. function goNext() {
  245. SubmitRequest();
  246. }
  247. //----------------------------------------------------------------
  248. // set a label to normal style
  249. function markLabelNormal(spn) {
  250. <%If "IE"=sBrowser Then%>
  251. spn.style.color="#000000";
  252. spn.style.fontWeight='normal';
  253. <%End If%>
  254. }
  255. //----------------------------------------------------------------
  256. // set a label to error state
  257. function markLabelError(spn) {
  258. <%If "IE"=sBrowser Then%>
  259. spn.style.color='#FF0000';
  260. spn.style.fontWeight='bold';
  261. <%End If%>
  262. }
  263. //----------------------------------------------------------------
  264. function validateRequest() {
  265. <%If "IE"<>sBrowser Then%>
  266. // work around for NN: label marking does nothing
  267. var spnPasteLabel;
  268. <%End If%>
  269. markLabelNormal(spnPasteLabel);
  270. // Check for an empty request
  271. if (""==document.UIForm.taRequest.value) {
  272. bOK=false;
  273. markLabelError(spnPasteLabel);
  274. <%If "IE"=sBrowser Then%>
  275. spnFixTxt.style.display='';
  276. window.scrollTo(0,0);
  277. <%Else%>
  278. alert(L_NoBlank_ErrorMessage);
  279. <%End If%>
  280. document.UIForm.taRequest.focus();
  281. return false;
  282. }
  283. // everything is OK
  284. return true;
  285. }
  286. //----------------------------------------------------------------
  287. function SubmitRequest() {
  288. <%If "IE"=sBrowser Then%>
  289. spnFixTxt.style.display='none';
  290. <%End If%>
  291. // check that the form is filled in
  292. if (false==validateRequest()) {
  293. return;
  294. }
  295. // set request
  296. document.SubmittedData.CertRequest.value=document.UIForm.taRequest.value;
  297. // set defaults for values we need on install
  298. document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store), but ignored when saving cert.
  299. document.SubmittedData.SaveCert.value="yes";
  300. document.SubmittedData.Mode.value="newreq";
  301. document.SubmittedData.FriendlyType.value=L_SavedReqCert_Text;
  302. // append the local date to the type
  303. document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  304. //not created by xenroll, not supported
  305. document.SubmittedData.ThumbPrint.value="";
  306. // make sure the arributes end cr/lf
  307. var sAttrib=document.UIForm.taAttrib.value;
  308. if (sAttrib.lastIndexOf("\r\n")!=sAttrib.length-2 && sAttrib.length>0) {
  309. sAttrib=sAttrib+"\r\n";
  310. }
  311. <%If "Enterprise"=sServerType Then%>
  312. // add an attribute for the cert type
  313. // get the selected template
  314. var sRealName = getTemplateStringInfo(CTINFO_INDEX_REALNAME, null);
  315. // set the cert template
  316. sAttrib+="CertificateTemplate:"+sRealName+"\r\n";
  317. <%End If%>
  318. // for interop debug purposes
  319. sAttrib+="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  320. // set the attributes
  321. document.SubmittedData.CertAttrib.value=sAttrib;
  322. // Submit the cert request and move forward in the wizard
  323. document.SubmittedData.submit();
  324. }
  325. </Script>
  326. <%If "IE"=sBrowser Then%>
  327. <Script Language="VBSCRIPT">
  328. '=================================================================
  329. ' FILE READ ROUTINES
  330. '-----------------------------------------------------------------
  331. ' IE SPECIFIC:
  332. ' See if we have permision to access the file system
  333. Function TestRead()
  334. Dim filesystem
  335. On Error Resume Next
  336. ' See if we're allowed to create the FileSystem object
  337. Set filesystem=CreateObject("Scripting.FileSystemObject")
  338. ' Security may not allow this
  339. If Err.Number<>0 Then
  340. TestRead=False
  341. Else
  342. TestRead=True
  343. End If
  344. End Function
  345. '-----------------------------------------------------------------
  346. ' IE SPECIFIC:
  347. ' read the given file into the text-area
  348. Function GetFileData()
  349. Dim filesystem, file
  350. On Error Resume Next
  351. ' First, create the FileSystem object
  352. Set filesystem=CreateObject("Scripting.FileSystemObject")
  353. ' Security may not allow this
  354. If Err.Number<>0 Then
  355. GetFileData=Err.Number
  356. Exit Function
  357. End If
  358. ' open the specified file
  359. Set file=filesystem.OpenTextFile(document.UIForm.flRequest.value, 1 , false) '1->ForReading, false->don't create
  360. ' file may not exist
  361. If Err.Number<>0 Then
  362. GetFileData=Err.Number
  363. Exit Function
  364. End If
  365. ' read the data and stash it into the form
  366. document.UIForm.taRequest.value=file.ReadAll
  367. ' catch any read errors
  368. If Err.Number<>0 Then
  369. GetFileData=Err.Number
  370. Exit Function
  371. End If
  372. ' clean up
  373. file.Close
  374. Set file=Nothing
  375. Set filesystem=Nothing
  376. GetFileData=0
  377. End Function
  378. </Script>
  379. <%End If '"IE"=sBrowser%>
  380. </Body>
  381. </HTML>