home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 July / PCWorld_2001-07_cd.bin / Software / Topware / w2ksp2en / w2ksp2.exe / i386 / certrqbi.as_ / certrqbi.asp
Encoding:
Text File  |  2001-05-04  |  26.8 KB  |  692 lines

  1. <%@ CODEPAGE=65001 'UTF-8%>
  2. <%' certrqbi.asp - (CERT)srv web - (R)e(Q)uest, (B)asic (I)nformation
  3.   ' Copyright (C) Microsoft Corporation, 1998 - 1999 %>
  4. <!-- #include FILE=certsbrt.inc -->
  5. <!-- #include FILE=certdat.inc -->
  6. <!-- #include FILE=certrqtp.inc -->
  7. <HTML>
  8. <Head>
  9.     <Meta HTTP-Equiv="Content-Type" Content="text/html; charset=UTF-8">
  10.     <Title>Microsoft Certificate Services</Title>
  11. </Head>
  12. <Body BgColor=#FFFFFF <%If "IE"=sBrowser Then%> OnLoad="postLoad();" <%End If%>><Font ID=locPageFont Face="Arial">
  13.  
  14. <Table Border=0 CellSpacing=0 CellPadding=4 Width=100% BgColor=#008080>
  15. <TR>
  16.     <TD><Font Color=#FFFFFF><LocID ID=locMSCertSrv><Font Face="Arial" Size=-1><B><I>Microsoft</I></B> Certificate Services  --  <%=sServerDisplayName%>  </Font></LocID></Font></TD>
  17.     <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>
  18. </TR>
  19. </Table>
  20.  
  21. <Form Name=UIForm OnSubmit="goNext();return false;" Action="certlynx.asp" Method=Post>
  22. <Input Type=Hidden Name=SourcePage Value="certrqbi">
  23.  
  24. <P ID=locPageTitle> <B> <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%> - Identifying Information </B>
  25. <!-- 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>
  26.  
  27. <%If True=bBrowserDHTML Then%>
  28. <Span ID=spnFixTxt Style="display:none">
  29.     <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000"><TR><TD ID=locBadCharError>
  30.         <I>Please correct the fields marked in <B>RED</B>.</I>
  31.         No field may contain the characters (, ; " +). The name field may not be blank.
  32.         The e-mail address may contain the characters A-Z, a-z, 0-9, and some common symbols, but no extended characters.
  33.         The country/region field must be a two letter ISO 3166 country/region code.
  34.     </TD></TR></Table>
  35. </Span>
  36. <Span ID=spnErrorTxt Style="display:none">
  37.     <Table Border=0 CellSpacing=0 CellPadding=4 Style="Color:#FF0000">
  38.     <TR><TD ID=locErrMsgBasic>
  39.         <B>An error occurred</B> while creating the certificate request. 
  40.         Please verify that you selected the correct CSP, or contact 
  41.         an administrator for assistance.
  42.     </TD></TR><TR><TD><Span ID=spnErrorDetailsBtn>
  43.         <Table Border=0 CellSpacing=0 CellPadding=0>
  44.         <TR> <TD Width=20></TD><TD>
  45.             <Input ID=locBtnDetails Type=Button Value="Details >>" OnClick="showErrorDetails();blur();">
  46.         </TD></TR>
  47.         </Table>
  48.     </Span></TD></TR><TR><TD><Span ID=spnErrorDetails1 Style="display:none">
  49.         <LocID ID=locErrorCause><B>Suggested cause:</B></LocID><BR>
  50.         <Span ID=spnErrorMsg></Span>
  51.     </Span></TD></TR><TR>
  52.         <TD><Span ID=spnErrorDetails2 Style="display:none"><LocID ID=locErrorNumber><Font Size=-2>Error: <Span ID=spnErrorNum></Span></Font></LocID></Span></TD>
  53.     </TR>
  54.     </Table>
  55. </Span>
  56. <%End If%>
  57.  
  58. <%If "StandAlone"=sServerType Then%>
  59. <P ID=locInstructions> Please fill in the following identifying information 
  60. that will go on your certificate:
  61. <Table Border=0 CellSpacing=0 CellPadding=0>
  62.     <TR> <!-- establish column widths. -->
  63.         <TD Height=4 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  64.         <TD RowSpan=10 Width=4></TD>                         <!-- label spacing column -->
  65.         <TD></TD>                                            <!-- field column -->
  66.     </TR><TR>
  67.         <TD ID=locNameAlign Align=Right><Span ID=spnNameLabel><LocID ID=locNameLabel><Font Face="Arial" Size=-1>Name:</Font></LocID></Span></TD>
  68.         <TD><Input ID=locTbCommonName Type=Text MaxLength=64 Size=42 Name=tbCommonName></TD>
  69.     </TR><TR>
  70.         <TD ID=locEmailAlign Align=Right><Span ID=spnEmailLabel><LocID ID=locEmailLabel><Font Face="Arial" Size=-1>E-Mail:</Font></LocID></Span></TD>
  71.         <TD><Input ID=locTbEmail Type=Text MaxLength=128 Size=42 Name=tbEmail></TD>
  72.     </TR><TR>
  73.         <TD Height=8></TD> <TD></TD>
  74.     </TR><TR>
  75.         <TD ID=locCompanyAlign Align=Right><Span ID=spnCompanyLabel><LocID ID=locOrgLabel><Font Face="Arial" Size=-1>Company:</Font></LocID></Span></TD>
  76.         <TD><Input ID=locTbOrg Type=Text MaxLength=64 Size=42 Name=tbOrg Value="<%=sDefaultCompany%>"></TD>
  77.     </TR><TR>
  78.         <TD ID=locDepartmentAlign Align=Right><Span ID=spnDepartmentLabel><LocID ID=locOrgUnitLabel><Font Face="Arial" Size=-1>Department:</Font></LocID></Span></TD>
  79.         <TD><Input ID=locTbOrgUnit Type=Text MaxLength=64 Size=42 Name=tbOrgUnit Value="<%=sDefaultOrgUnit%>"></TD>
  80.     </TR><TR>
  81.         <TD Height=8></TD> <TD></TD>
  82.     </TR><TR>
  83.         <TD ID=locCityAlign Align=Right><Span ID=spnCityLabel><LocID ID=locLocalityLabel><Font Face="Arial" Size=-1>City:</Font></LocID></Span></TD>
  84.         <TD><Input ID=locTbLocality Type=Text MaxLength=128 Size=42 Name=tbLocality Value="<%=sDefaultLocality%>"></TD>
  85.     </TR><TR>
  86.         <TD ID=locStateAlign Align=Right><Span ID=spnStateLabel><LocID ID=locStateLabel><Font Face="Arial" Size=-1>State:</Font></LocID></Span></TD>
  87.         <TD><Input ID=locTbState Type=Text MaxLength=128 Size=42 Name=tbState Value="<%=sDefaultState%>"></TD>
  88.     </TR><TR>
  89.         <TD ID=locCountryAlign Align=Right><Span ID=spnCountryLabel><LocID ID=locCountryLabel><Font Face="Arial" Size=-1>Country/Region:</Font></LocID></Span></TD>
  90.         <TD><Input ID=locTbCountry Type=Text MaxLength=2 Size=2 Name=tbCountry Value="<%=sDefaultCountry%>"></TD>
  91.     </TR>
  92. </Table>
  93. </P>
  94. <%Else%>
  95. <P ID=locReadyToGo> All the necessary identifying information has already been collected. You may now submit your request. </P>
  96. <%End If%>
  97.     
  98. <%If "IE"=sBrowser Then%>
  99. <%If True=bBrowserDHTML Then%>
  100. <Span ID=spnMoreOptionsBtn>
  101. <P>
  102. <Table Border=0 CellSpacing=0 CellPadding=0>
  103. <TR> <TD Width=20></TD><TD>
  104.     <Input ID=locBtnMoreOpt Type=Button Value="More Options >>" OnClick="showMoreOptions();blur();">
  105. </TD></TR>
  106. </Table>
  107. </P>
  108. </Span>
  109.  
  110. <Span ID=spnMoreOptionsText Style="display:'none'">
  111. <P> 
  112. <%End If%>
  113. <P ID=locMoreOptHead><Font Size=-1><B> More Options </B></Font>
  114. <!-- 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>
  115. <!-- 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>
  116. <LocID ID=locCSPInstr>Select a Cryptographic Service Provider:
  117. <Table Border=0 CellSpacing=0 CellPadding=0>
  118.     <TR>
  119.         <TD Height=4 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  120.         <TD RowSpan=4 Width=4></TD>                          <!-- label spacing column -->
  121.         <TD></TD>                                            <!-- field column -->
  122.     </TR><TR>
  123.         <TD ID=locCSPLabel Align=Right><Font Size=-1>CSP:</Font></TD>
  124.         <TD><Select Name=lbCSP>
  125.             <Option ID=locLoading>Loading...</Option>
  126.             </Select>
  127.         </TD>
  128.     </TR><TR>
  129.         <TD Height=8></TD> <TD></TD>
  130.     </TR><TR>
  131.         <TD></TD>
  132.         <TD>
  133.             <Table Border=0 CellSpacing=0 CellPadding=0><TR>
  134.                 <TD><Input Type=Checkbox ID=cbStrongKey Name=cbStrongKey></TD>
  135.                 <TD><Font Size=-1><Label For=cbStrongKey ID=locStrongKeyLabel>Enable strong private key protection</Label></Font></TD>
  136.             </TR></Table>
  137.         </TD>
  138.     </TR>
  139. </Table>
  140. <BR><LocID ID=locAdvancedLink><Font Size=-1>If you need an advanced option that is not here, please use 
  141. the <A Href="certrqma.asp">Advanced Certificate Request</A> form.</Font></P>
  142.  
  143. <%If True=bBrowserDHTML Then%>
  144. </Span>
  145. <%End If%>
  146. <%End If '"IE"=sBrowser%>
  147.  
  148. <%If "NN"=sBrowser Then%>
  149. </Form>
  150. <Form Name=SubmittedData Action="certfnsh.asp" OnSubmit="return goNext();" Method=Post>
  151.     <Input Type=Hidden Name=Mode>             <!-- used in request ('newreq'|'chkpnd') -->
  152. <!--<Input Type=Hidden Name=CertRequest>-->   <!-- used in request -->
  153.     <Input Type=Hidden Name=CertAttrib>       <!-- used in request -->
  154.     <Input Type=Hidden Name=FriendlyType>     <!-- used on pending -->
  155.     <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  156.     <Input Type=Hidden Name=SaveCert>         <!-- used on install ('no'|'yes')-->
  157.  
  158. <P ID=locStrengthInst> Please select a key strength:
  159.     <Table Border=0 CellSpacing=0 CellPadding=0>
  160.         <TR>
  161.             <TD Height=4 Width=<%=L_LabelColWidth_Number%>></TD> <!-- label column, top border -->
  162.             <TD RowSpan=2 Width=4></TD>                          <!-- label spacing column -->
  163.             <TD></TD>                                            <!-- field column -->
  164.         </TR><TR>
  165.             <TD ID=locStrengthLabel Align=Right><Font Face="Arial" Size=-1>Key Strength:</Font></TD>
  166.             <TD><KeyGen Name=CertRequest Challenge="provePequalsNP"></TD>
  167.         </TR>
  168.     </Table>
  169. </P>
  170. <%End If '"NN"=sBrowser%>
  171.  
  172.  
  173. <!-- 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>
  174. <!-- 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>
  175.  
  176. <Table Width=100% Border=0 CellPadding=0 CellSpacing=0><TR><TD ID=locSubmitAlign Align=Right>
  177.     <Input ID=locBtnSubmit Type=Submit Name=btnSubmit Value="Submit >" <%If "IE"=sBrowser Then%> Style="width:.75in"<%End If%>>
  178.          
  179. </TD></TR></Table>
  180.  
  181. </Form>
  182. </Font>
  183. <!-- ############################################################ -->
  184. <!-- End of standard text. Scripts follow  -->
  185.  
  186. <%bIncludeXEnroll=True%>
  187. <%bIncludeGetCspList=True%>
  188. <!-- #include FILE=certsgcl.inc -->
  189.  
  190. <%If "IE"=sBrowser Then%>
  191. <!-- IE SPECIFIC: This form we fill in and submit 'by hand'. NN does it differently. -->
  192. <Form Name=SubmittedData Action="certfnsh.asp" Method=Post>
  193.     <Input Type=Hidden Name=Mode>             <!-- used in request ('newreq'|'chkpnd') -->
  194.     <Input Type=Hidden Name=CertRequest>      <!-- used in request -->
  195.     <Input Type=Hidden Name=CertAttrib>       <!-- used in request -->
  196.     <Input Type=Hidden Name=FriendlyType>     <!-- used on pending -->
  197.     <Input Type=Hidden Name=TargetStoreFlags> <!-- used on install ('0'|CSSLM)-->
  198.     <Input Type=Hidden Name=SaveCert>         <!-- used on install ('no'|'yes')-->
  199. </FORM>
  200. <%End If%>
  201.  
  202. <Script Language="JavaScript">
  203.  
  204.     //================================================================
  205.     // PAGE GLOBAL VARIABLES
  206.  
  207.     //----------------------------------------------------------------
  208.     // Strings to be localized
  209.     var L_CspLoadErrNoneFound_ErrorMessage="An unexpected error occurred while getting the CSP list:\nNo CSPs could be found!";
  210.     var L_CspLoadErrUnexpected_ErrorMessage="\"An unexpected error (\"+sErrorNumber+\") occurred while getting the CSP list.\"";
  211.     var L_StillLoading_ErrorMessage="This page has not finished loading yet. Please wait a few seconds and try again.";
  212.     var L_Generating_Message="Generating request...";
  213.     var L_Waiting_Message="Waiting for server response...";
  214.     var L_ErrNameUnknown_ErrorMessage="(unknown)";
  215.     var L_SugCauseNone_ErrorMessage="No suggestion.";
  216.     var L_SugCauseBadCSP_ErrorMessage="The CSP you chose was unable to process the request. Try a different CSP.";
  217.     var L_SugCauseBadSetting_ErrorMessage="The CSP you chose does not support one or more of the settings you have made. Try using different settings or a different CSP.";
  218.     var L_SugCauseBadChar_ErrorMessage="You entered an invalid character. Report a bug, because this should have been caught in validation.";
  219.     <%If False=bBrowserDHTML Then%>
  220.     ;
  221.     var L_BadChars_ErrorMessage="No field may contain the characters (, ; \" +). The name field may not be blank. The e-mail address may contain the characters A-Z, a-z, 0-9, and some common symbols, but no extended characters. The country/region field must be a two letter ISO 3166 country/region code.";
  222.     var L_CertGenFailed_ErrorMessage="\"An error occurred while creating the certificate request. Please verify that your CSP supports any settings you have made and that your input is valid.\\n\\nSuggested cause:\\n    \"+sSugCause+\"\\n\\nError: \"+sErrorNum";
  223.     <%End If%>
  224.  
  225.  
  226.     <%If "IE"=sBrowser Then%>
  227.     // IE is not ready until XEnroll has been loaded
  228.     var g_bOkToSubmit=false;
  229.     <%Else%>
  230.     //  We start with this variable true since it doesn't do anything
  231.     //  for Netscape anyway.
  232.     var g_bOkToSubmit=true;
  233.     <%End If%>
  234.  
  235.     //================================================================
  236.     // INITIALIZATION ROUTINES
  237.  
  238.     <%If "IE"=sBrowser Then%>
  239.     //----------------------------------------------------------------
  240.     // IE SPECIFIC: 
  241.     // This contains the functions we want executed immediately after load completes
  242.     function postLoad() {
  243.         // Load an XEnroll object into the page
  244.         loadXEnroll("postLoadPhase2()"); 
  245.     }
  246.     function postLoadPhase2() {
  247.         // continued from above
  248.         var nResult;
  249.  
  250.         // get the CSP list
  251.         nResult=GetCSPList();
  252.         if (0!=nResult) {
  253.             handleLoadError(nResult, L_CspLoadErrNoneFound_ErrorMessage, L_CspLoadErrUnexpected_ErrorMessage);
  254.             return;
  255.         }
  256.  
  257.         // Now we're ready to go
  258.         g_bOkToSubmit=true;
  259.     }
  260.     <%End If%>
  261.  
  262.     <%If "IE"=sBrowser Then%>
  263.     //----------------------------------------------------------------
  264.     // IE SPECIFIC: handle errors from GetCSPList() and GetTemplateList()
  265.     function handleLoadError(nResult, sNoneFound, sUnexpected) {
  266.         if (-1==nResult) {
  267.             alert(sNoneFound);
  268.         } else {
  269.             var sErrorNumber="0x"+toHex(nResult);
  270.             alert(eval(sUnexpected));
  271.         }
  272.         disableAllControls();
  273.     }
  274.     <%End If%>
  275.  
  276.     //================================================================
  277.     // PAGE MANAGEMENT ROUTINES
  278.  
  279.     <%If True=bBrowserDHTML Then%>
  280.     //----------------------------------------------------------------
  281.     // morph method for the error details drop-down
  282.     function showErrorDetails() {
  283.         spnErrorDetailsBtn.style.display='none';
  284.         spnErrorDetails1.style.display='';
  285.         spnErrorDetails2.style.display='';
  286.     }
  287.  
  288.     //----------------------------------------------------------------
  289.     // morph method for the "more options" drop down
  290.     function showMoreOptions() {
  291.         spnMoreOptionsBtn.style.display='none';
  292.         spnMoreOptionsText.style.display='';
  293.     }
  294.     <%End If%>
  295.         
  296.     //================================================================
  297.     // SUBMIT ROUTINES
  298.  
  299.     //----------------------------------------------------------------
  300.     // determine what to do when the submit button is pressed
  301.     function goNext() {
  302.         if (false==g_bOkToSubmit) {
  303.             alert(L_StillLoading_ErrorMessage);
  304.             return false;
  305.         } else {
  306.             return SubmitRequest();
  307.         }
  308.     }
  309.  
  310.     <%If "StandAlone"=sServerType Then%>
  311.     //----------------------------------------------------------------
  312.     // check for invalid characters and empty strings
  313.     function isValidX500String(sSource) {
  314.         if (-1!=sSource.indexOf(",",0) ||
  315.             -1!=sSource.indexOf("\"",0) ||
  316.             -1!=sSource.indexOf("+",0) ||
  317.             -1!=sSource.indexOf(";",0)) {
  318.             return false;
  319.         } else {
  320.             return true;
  321.         }
  322.     }
  323.  
  324.     //----------------------------------------------------------------
  325.     // check for invalid characters
  326.     var gc_IA5Chars=" !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKMLNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~"
  327.     function isValidIA5String(sSource) {
  328.         var nIndex;
  329.         for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  330.             //if (sSource.charCodeAt(nIndex)>127) {  // NOTE: this is better, but not compatible with old browsers.
  331.             if (-1==gc_IA5Chars.indexOf(sSource.charAt(nIndex))) {
  332.                 return false;
  333.             }
  334.         };
  335.         return true;
  336.     }
  337.  
  338.     //----------------------------------------------------------------
  339.     // check for invalid characters
  340.     function isValidCountryField(tbCountry) {
  341.         tbCountry.value=tbCountry.value.toUpperCase();
  342.         var sSource=tbCountry.value;
  343.         var nIndex, ch;
  344.         if (0!=sSource.length && 2!=sSource.length) {
  345.             return false;
  346.         }
  347.         for (nIndex=sSource.length-1; nIndex>=0; nIndex--) {
  348.             ch=sSource.charAt(nIndex)
  349.             if (ch<"A" || ch>"Z") {
  350.                 return false;
  351.             }
  352.         };
  353.         return true;
  354.     }
  355.  
  356.     //----------------------------------------------------------------
  357.     // set a label to normal style
  358.     function markLabelNormal(spn) {
  359.         <%If True=bBrowserDHTML Then%>
  360.         spn.style.color="#000000";
  361.         spn.style.fontWeight='normal';
  362.         <%End If%>
  363.     }
  364.  
  365.     //----------------------------------------------------------------
  366.     // set a label to error state
  367.     function markLabelError(spn) {
  368.         <%If True=bBrowserDHTML Then%>
  369.         spn.style.color='#FF0000';
  370.         spn.style.fontWeight='bold';
  371.         <%End If%>
  372.     }
  373.  
  374.     //----------------------------------------------------------------
  375.     // check that the form has data in it
  376.     function validateRequest() {
  377.         <%If False=bBrowserDHTML Then%>
  378.         // work around for NN: label marking does nothing
  379.         var spnNameLabel, spnEmailLabel, spnCompanyLabel, spnDepartmentLabel, spnCityLabel, spnStateLabel, spnCountryLabel;
  380.         <%End If%>
  381.  
  382.         markLabelNormal(spnNameLabel);
  383.         markLabelNormal(spnEmailLabel);
  384.         markLabelNormal(spnCompanyLabel);
  385.         markLabelNormal(spnDepartmentLabel);
  386.         markLabelNormal(spnCityLabel);
  387.         markLabelNormal(spnStateLabel);
  388.         markLabelNormal(spnCountryLabel);
  389.         
  390.         var bOK=true;
  391.         var fldFocusMe=null;
  392.         // check in 'reverse' order so that focus gets set to last item
  393.         // don't set focus immediately because we'd get funny scrolling effects.
  394.         if (false==isValidCountryField(document.UIForm.tbCountry)) {
  395.             bOK=false;
  396.             fldFocusMe=document.UIForm.tbCountry;
  397.             markLabelError(spnCountryLabel);
  398.         }
  399.         if (false==isValidX500String(document.UIForm.tbState.value)) {
  400.             bOK=false;
  401.             fldFocusMe=document.UIForm.tbState;
  402.             markLabelError(spnStateLabel);
  403.         }
  404.         if (false==isValidX500String(document.UIForm.tbLocality.value)) {
  405.             bOK=false;
  406.             fldFocusMe=document.UIForm.tbLocality;
  407.             markLabelError(spnCityLabel);
  408.         }
  409.         if (false==isValidX500String(document.UIForm.tbOrgUnit.value)) {
  410.             bOK=false;
  411.             fldFocusMe=document.UIForm.tbOrgUnit;
  412.             markLabelError(spnDepartmentLabel);
  413.         }
  414.         if (false==isValidX500String(document.UIForm.tbOrg.value)) {
  415.             bOK=false;
  416.             fldFocusMe=document.UIForm.tbOrg;
  417.             markLabelError(spnCompanyLabel);
  418.         }
  419.         if (false==isValidX500String(document.UIForm.tbEmail.value) || false==isValidIA5String(document.UIForm.tbEmail.value)) {
  420.             bOK=false;
  421.             fldFocusMe=document.UIForm.tbEmail;
  422.             markLabelError(spnEmailLabel);
  423.         }
  424.         if (false==isValidX500String(document.UIForm.tbCommonName.value) || ""==document.UIForm.tbCommonName.value) {
  425.             bOK=false;
  426.             fldFocusMe=document.UIForm.tbCommonName;
  427.             markLabelError(spnNameLabel);
  428.         }
  429.  
  430.         if (false==bOK) {
  431.             <%If True=bBrowserDHTML Then%>
  432.             spnFixTxt.style.display='';
  433.             window.scrollTo(0,0);
  434.             <%Else%>
  435.             alert (L_BadChars_ErrorMessage);
  436.             <%End If%>
  437.             fldFocusMe.focus();
  438.         }
  439.  
  440.         return bOK;
  441.     }
  442.     <%End If '"StandAlone"=sServerType%>
  443.  
  444.  
  445.  
  446.     <%If "IE"=sBrowser Then%>
  447.     //----------------------------------------------------------------
  448.     // IE SPECIFIC:
  449.     function SubmitRequest() {
  450.  
  451.         spnErrorTxt.style.display='none';
  452.         spnFixTxt.style.display='none';
  453.  
  454.         <%If "StandAlone"=sServerType Then%>
  455.         // check that the form is filled in
  456.         if (false==validateRequest()) {
  457.             return;
  458.         }
  459.         <%End If%>
  460.  
  461.         // show a nice message since request creation can take a while
  462.         ShowTransientMessage(L_Generating_Message);
  463.     
  464.         // Make the message show up on the screen,
  465.         // then continue with 'SubmitRequest':
  466.         // Pause 1 mS before executing phase 2,
  467.         // so screen will have time to repaint.
  468.         setTimeout("SubmitRequestPhase2();",1);
  469.     }
  470.     function SubmitRequestPhase2() {
  471.         // continued from above
  472.  
  473.         // some constants defined in wincrypt.h: (line ~234)
  474.         var CRYPT_EXPORTABLE=1;
  475.         var CRYPT_USER_PROTECTED=2;
  476.         var AT_KEYEXCHANGE=1;
  477.         var AT_SIGNATURE=2;
  478.         var PROV_DSS=3;
  479.         var PROV_DSS_DH=13;
  480.  
  481.         <%If "StandAlone"=sServerType Then%>
  482.         // set the identifying info
  483.         var sDistinguishedName="";
  484.         if (""!=document.UIForm.tbCountry.value) {
  485.             sDistinguishedName+="C=\""+document.UIForm.tbCountry.value.replace(/"/g, "\"\"")   +"\";";
  486.         }
  487.         if (""!=document.UIForm.tbState.value) {
  488.             sDistinguishedName+="S=\""+document.UIForm.tbState.value.replace(/"/g, "\"\"")     +"\";";
  489.         }
  490.         if (""!=document.UIForm.tbLocality.value) {
  491.             sDistinguishedName+="L=\""+document.UIForm.tbLocality.value.replace(/"/g, "\"\"")  +"\";";
  492.         }
  493.         if (""!=document.UIForm.tbOrg.value) {
  494.             sDistinguishedName+="O=\""+document.UIForm.tbOrg.value.replace(/"/g, "\"\"")       +"\";";
  495.         }
  496.         if (""!=document.UIForm.tbOrgUnit.value) {
  497.             sDistinguishedName+="OU=\""+document.UIForm.tbOrgUnit.value.replace(/"/g, "\"\"")   +"\";";
  498.         }
  499.         if (""!=document.UIForm.tbEmail.value) {
  500.             sDistinguishedName+="E=\""+document.UIForm.tbEmail.value.replace(/"/g, "\"\"")     +"\";";
  501.         }
  502.         if (""!=document.UIForm.tbCommonName.value) {
  503.             sDistinguishedName+="CN=\""+document.UIForm.tbCommonName.value.replace(/"/g, "\"\"")+"\";";
  504.         }
  505.         <%Else%>
  506.         // the distinguished name is not used for enterprise CAs
  507.         var sDistinguishedName="";
  508.         <%End If%>
  509.  
  510.         // set defaults for values we need on install
  511.         document.SubmittedData.CertAttrib.value="UserAgent:<%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  512.         document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store)
  513.         document.SubmittedData.SaveCert.value="no";
  514.         document.SubmittedData.Mode.value="newreq";
  515.         document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  516.         // append the local date to the type
  517.         document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  518.  
  519.         <%If "StandAlone"=sServerType Then%>
  520.  
  521.         // set the cert type information
  522.         var sCertUsage="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>";
  523.         DoEkuSpecificSettings(sCertUsage);
  524.  
  525.         <%Else%>
  526.  
  527.         // set the cert template
  528.         XEnroll.addCertTypeToRequest("<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>");
  529.         <%If True=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_NEEDS_SMIME_CAPABILITIES) Then%>
  530.             XEnroll.EnableSMIMECapabilities=true;
  531.         <%End If%>
  532.  
  533.         var sCertUsage=""; // ignored
  534.  
  535.         <%End If%>
  536.         
  537.         // set the CSP
  538.         var nCSPIndex=document.UIForm.lbCSP.selectedIndex;
  539.         XEnroll.ProviderName=document.UIForm.lbCSP.options[nCSPIndex].text;
  540.         var nProvType=document.UIForm.lbCSP.options[nCSPIndex].value
  541.         XEnroll.ProviderType=nProvType;
  542.  
  543.         // default to exchange keys, unless we're doing DSS which only does sig.
  544.         if (PROV_DSS==nProvType || PROV_DSS_DH==nProvType) {
  545.             XEnroll.KeySpec=AT_SIGNATURE;
  546.         } else {
  547.             XEnroll.KeySpec=AT_KEYEXCHANGE;
  548.         }
  549.  
  550.         // set 'Strong private key protection'
  551.         if (document.UIForm.cbStrongKey.checked) {
  552.             XEnroll.GenKeyFlags|=CRYPT_USER_PROTECTED;
  553.         }
  554.  
  555.         
  556.         // build the certificate request
  557.         var nResult=CreateRequest(sDistinguishedName, sCertUsage); // ask VB to do it, since it can handle errors
  558.  
  559.         // hide the message box
  560.         HideTransientMessage();
  561.  
  562.         // deal with an error if there was one
  563.         if (0!=nResult) {
  564.             handleError(nResult);
  565.             return;
  566.         }
  567.  
  568.         // put up a new wait message
  569.         ShowTransientMessage(L_Waiting_Message);
  570.  
  571.         // Submit the cert request and move forward in the wizard
  572.         document.SubmittedData.submit();
  573.     }
  574.  
  575.     //----------------------------------------------------------------
  576.     // IE SPECIFIC:
  577.     function handleError(nResult) {
  578.         var sSugCause=L_SugCauseNone_ErrorMessage;
  579.         var sErrorName=L_ErrNameUnknown_ErrorMessage;
  580.         // analyze the error - funny use of XOR ('^') because obvious choice '==' doesn't work
  581.         if (0==(0x80090008^nResult)) {
  582.             sErrorName="NTE_BAD_ALGID";
  583.             sSugCause=L_SugCauseBadCSP_ErrorMessage;
  584.         } else if (0==(0x80090016^nResult)) {
  585.             sErrorName="NTE_BAD_KEYSET";
  586.             sSugCause=L_SugCauseBadCSP_ErrorMessage;
  587.         } else if (0==(0x80090019^nResult)) {
  588.             sErrorName="NTE_KEYSET_NOT_DEF";
  589.             sSugCause=L_SugCauseBadCSP_ErrorMessage;
  590.         } else if (0==(0x80090020^nResult)) {
  591.             sErrorName="NTE_FAIL";
  592.             sSugCause=L_SugCauseBadCSP_ErrorMessage;
  593.         } else if (0==(0x80090009^nResult)) {
  594.             sErrorName="NTE_BAD_FLAGS";
  595.             sSugCause=L_SugCauseBadSetting_ErrorMessage;
  596.         } else if (0==(0x80092002^nResult)) {
  597.             sErrorName="CRYPT_E_BAD_ENCODE";
  598.             //sSugCause="";
  599.         } else if (0==(0x80092022^nResult)) {
  600.             sErrorName="CRYPT_E_INVALID_IA5_STRING";
  601.             sSugCause=L_SugCauseBadChar_ErrorMessage;
  602.         } else if (0==(0x80092023^nResult)) {
  603.             sErrorName="CRYPT_E_INVALID_X500_STRING";
  604.             sSugCause=L_SugCauseBadChar_ErrorMessage;
  605.         } else if (0==(0x8000FFFF^nResult)) {
  606.             sErrorName="E_UNEXPECTED";
  607.         }
  608.         
  609.         var sErrorNum="0x"+toHex(nResult)+" - "+sErrorName;
  610.  
  611.         <%If True=bBrowserDHTML Then%>
  612.         // modify the document text and appearance to show the error message
  613.         spnErrorNum.innerText=sErrorNum;
  614.         spnErrorMsg.innerText=sSugCause;
  615.         spnFixTxt.style.display='none';
  616.         spnErrorTxt.style.display='';
  617.  
  618.         // back to the top so the messages show
  619.         window.scrollTo(0,0);
  620.         <%Else%>
  621.         alert(eval(L_CertGenFailed_ErrorMessage));
  622.         <%End If%>
  623.  
  624.         // reset XEnroll so the user can select a different CSP, etc.
  625.         XEnroll.reset();
  626.     }
  627.  
  628.     <%Else '"NN"=sBrowser%>
  629.  
  630.     //----------------------------------------------------------------
  631.     // NN SPECIFIC:
  632.     function SubmitRequest() {
  633.  
  634.         <%If "StandAlone"=sServerType Then%>
  635.         // check that the form is filled in
  636.         if (false==validateRequest()) {
  637.             return false;
  638.         }
  639.         <%End If%>
  640.  
  641.         ShowTransientMessage("Generating request...");
  642.     
  643.         // set defaults for values we need on install
  644.         document.SubmittedData.CertAttrib.value="challenge: provePequalsNP\r\n"
  645.             <%If "StandAlone"=sServerType Then%>
  646.             +   "country: "+document.UIForm.tbCountry.value   +"\r\n"
  647.             +     "state: "+document.UIForm.tbState.value     +"\r\n"
  648.             +  "locality: "+document.UIForm.tbLocality.value  +"\r\n"
  649.             +       "org: "+document.UIForm.tbOrg.value       +"\r\n"
  650.             +   "orgunit: "+document.UIForm.tbOrgUnit.value   +"\r\n"
  651.             +     "email: "+document.UIForm.tbEmail.value     +"\r\n"
  652.             +"commonname: "+document.UIForm.tbCommonName.value+"\r\n"
  653.             <%End If%>
  654.             <%If "StandAlone"=sServerType Then%>
  655.             +"CertificateUsage:    <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_OID)%>\r\n"
  656.             <%Else%>
  657.             +"CertificateTemplate: <%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_TEMPLATE)%>\r\n"
  658.             <%End If%>
  659.             +"UserAgentString: <%=Request.ServerVariables("HTTP_USER_AGENT")%>\r\n";
  660.  
  661.         document.SubmittedData.TargetStoreFlags.value=0; // 0=Use default (=user store), but ignored by Netscape
  662.         document.SubmittedData.SaveCert.value="no";
  663.         document.SubmittedData.Mode.value="newreq NN";
  664.         document.SubmittedData.FriendlyType.value="<%=rgAvailReqTypes(CInt(Request.QueryString("type")), FIELD_FRIENDLYNAME)%>";
  665.         // append the local date to the type
  666.         document.SubmittedData.FriendlyType.value+=" ("+(new Date()).toLocaleString()+")";
  667.  
  668.         // keygen and submit
  669.         return true;
  670.     }
  671.  
  672.     <%End If%>
  673.  
  674. </Script> 
  675.  
  676. <%If "IE"=sBrowser Then%>
  677. <Script Language="VBSCRIPT">
  678.     '-----------------------------------------------------------------
  679.     ' IE SPECIFIC:
  680.     ' call XEnroll to create a request, since javascript has no error handling
  681.     Function CreateRequest(sDistinguishedName, sCertUsage)
  682.         On Error Resume Next
  683.         document.SubmittedData.CertRequest.value= _
  684.             XEnroll.CreatePKCS10(sDistinguishedName, sCertUsage)
  685.         CreateRequest=Err.Number
  686.     End Function
  687. </Script> 
  688. <%End If%>
  689.  
  690. </Body>
  691. </HTML>
  692.