home *** CD-ROM | disk | FTP | other *** search
/ Chip 2000 July / Chip_2000-07_cd.bin / servis / SPNT / sp6x86.exe / ceenroll.asp < prev    next >
Encoding:
Text File  |  1999-12-15  |  13.2 KB  |  437 lines

  1. <%Response.Expires=0%>
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Certificate Server Enrollment Form</TITLE>
  5. <META HTTP-EQUIV="Cache-Control" CONTENT="no cache">
  6. <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  7. <META HTTP-EQUIV="Pragma" CONTENT="no cache">
  8. <META HTTP-EQUIV="Expires" CONTENT="0">
  9.  
  10.  
  11. <%  Set BrowserCap = Server.CreateObject("MSWC.BrowserType") 
  12.  
  13.     Dim ControlType, BrowserType, BrowserString, BrowserVersion
  14.     Dim StrIndex, Devisor 
  15.  
  16.     ControlType = "UNKNOWN"
  17.     BrowserType = "" 
  18.     BrowserString = ""
  19.     R_BrowserVersion = 0
  20.     BrowserVersion = 0
  21.     Devisor = 10
  22.       
  23.     if Request.Form("sBrowser") = "" then 
  24.     BrowserType = UCase(BrowserCap.browser)
  25.     BrowserString = BrowserCap.version        
  26.     else
  27.     if Request.Form("sBrowser") = "IE4" then
  28.          ControlType = "XENROLL"
  29.         elseif Request.Form("sBrowser") = "IE3" then
  30.          ControlType = "CERTENR3"
  31.         elseif Request.Form("sBrowser") = "NETSCAPE" then
  32.          ControlType = "NETSCAPE"
  33.         end if
  34.     end if
  35.  
  36.     if BrowserType = "IE" and ControlType = "UNKNOWN" then    
  37.          StrIndex = InStr(BrowserString, ".")
  38.          if StrIndex > 0 then
  39.             BrowserVersion = Left(BrowserString, StrIndex-1)     
  40.             
  41.             if (BrowserVersion = 3) then
  42.               StrLength = Len(BrowserString)
  43.               while StrLength >= StrIndex+1
  44.                if mid(BrowserString, StrIndex+1, 1) > 0 then
  45.                   BrowserVersion = BrowserVersion + (mid(BrowserString, StrIndex+1, 1)/Devisor)
  46.                   Devisor = 10
  47.                else 
  48.                   Devisor = Devisor*10
  49.                end if
  50.                StrIndex = StrIndex +1
  51.               wend
  52.             end if
  53.          else
  54.             BrowserVersion = BrowserString
  55.          end if
  56.  
  57.      if BrowserVersion < 3 then
  58.          ControlType = ""
  59.       
  60.      elseif BrowserVersion = 3 and _    
  61.          Instr(UCase(Request.ServerVariables("HTTP_UA_CPU")), "ALPHA") = 0 then
  62.           ControlType = "CERTENR3"
  63.      
  64.          elseif BrowserVersion > (3+(2/100)) then
  65.              ControlType = "XENROLL"
  66.              
  67.      elseif BrowserVersion = (3+(2/100)) and _
  68.                 Instr(UCase(Request.ServerVariables("HTTP_USER_AGENT")), "UPDATE") > 0 then
  69.              ControlType = "XENROLL"
  70.  
  71.      elseif BrowserVersion <= 3+(2/100) and _
  72.                 Instr(UCase(Request.ServerVariables("HTTP_UA_CPU")), "ALPHA") = 0 then
  73.          ControlType = "CERTENR3"
  74.              BrowserVersion = 3         
  75.  
  76.      else
  77.              ControlType = ""
  78.              BrowserVersion = 0     
  79.          end if 
  80.  
  81.     elseif BrowserType = "NETSCAPE" and ControlType = "UNKNOWN" then
  82.          ControlType = "NETSCAPE"
  83.          BrowserVersion = 1
  84.     end if  
  85. %>
  86.  
  87.  
  88. <% if (ControlType = "XENROLL") then %>
  89.       
  90.       <OBJECT
  91.         classid="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
  92.         CODEBASE="/CertControl/xenroll.cab#Version=5,131,2090,1"       
  93.         id=IControl
  94.         >
  95.       </OBJECT>
  96.   
  97.  
  98. <% elseif ControlType = "CERTENR3" then %>
  99.       
  100.       <OBJECT
  101.         classid="clsid:33BEC9E0-F78F-11cf-B782-00C04FD7BF43"
  102.         CODEBASE="/CertControl/x86/certenr3.dll#Version=4,70,1143"
  103.         id=IControl
  104.       >
  105.       </OBJECT>
  106.  
  107. <% end if %>
  108.  
  109.  
  110. <% if ControlType <> "NETSCAPE" and ControlType <> "UNKNOWN" then %> 
  111.  
  112.  
  113. <SCRIPT LANGUAGE="JAVASCRIPT">
  114. <!--
  115.    function geterror(message, url, value) {
  116.  
  117.      if (message == "Out of memory") {
  118.        msg = "Xenroll is unable to generate a PKCS10:\n\n Please verify ";
  119.        msg = msg + "that your CSP supports any settings you have made \n";
  120.        msg = msg + "and that your input is valid."; 
  121.        
  122.        alert(msg);
  123.        
  124.        return true;
  125.      }
  126.      else 
  127.        return false;
  128.   }
  129. -->
  130. </SCRIPT>
  131.  
  132.  
  133.  
  134.  <SCRIPT LANGUAGE="JAVASCRIPT">
  135. <!--
  136.    function SubmitRequest() {
  137.   
  138.     CommonName = document.ReqForm.CommonName.value;
  139.     OrgUnit = document.ReqForm.OrgUnit.value;
  140.     Org = document.ReqForm.Org.value;
  141.     Locality = document.ReqForm.Locality.value;
  142.     State = document.ReqForm.State.value;
  143.     Country = document.ReqForm.Country.value;
  144.  
  145.     szPKCS10 = "";
  146.  
  147.     DN = "";
  148.     DN = DN + "C=" + Country + ";";
  149.     DN = DN + "S=" + State + ";";
  150.     DN = DN + "L=" + Locality + ";";
  151.     DN = DN + "O=" + Org + ";";
  152.     DN = DN + "OU=" + OrgUnit + ";";
  153.     DN = DN + "CN=" + CommonName + ";";
  154.     
  155.   <% if ControlType <> "CERTENR3" then %>
  156.     Email= document.ReqForm.Email.value;
  157.     DN = DN + "Email=" + Email + ";";
  158.   <% end if %>
  159.      
  160.   <% if ControlType = "XENROLL" then %>
  161.   
  162.     onerror=geterror; 
  163.    
  164.     <% if Request.Form("CertUsage") = "" then %>
  165.         IControl.KeySpec = 1;
  166.         document.ReqData.CertUsage.value = "1.3.6.1.5.5.7.3.2";
  167.     <% else %>
  168.         
  169.       if ("<%=Request.Form("ContainerName")%>" != "") 
  170.         IControl.ContainerName = "<%=Request.Form("ContainerName")%>";
  171.  
  172.       if ("<%=Request.Form("ProviderName")%>" != "") {
  173.          IControl.ProviderName = "<%=Request.Form("ProviderName")%>";
  174.          IControl.ProviderType =  <%=Request.Form("ProviderType")%>;
  175.        }
  176.  
  177.       if ("<%=Request.Form("HashAlgorithm")%>" != "")  
  178.          IControl.HashAlgorithm = "<%=Request.Form("HashAlgorithm")%>"
  179.     
  180.       IControl.GenKeyFlags = <%=Request.Form("GenKeyFlag")%>;
  181.       if ("<%=Request.Form("ExportKeys")%>" != "")  
  182.          IControl.PVKFileName = "<%=Request.Form("ExportKeys")%>";
  183.        
  184.       document.ReqData.CertUsage.value = "<%=Request.Form("CertUsage")%>";      
  185.       document.ReqData.WriteCertToCSP.value = "<%=Request.Form("WriteCertToCSP")%>";
  186.       document.ReqData.SaveCert.value = "<%=Request.Form("SaveCert")%>";
  187.       IControl.KeySpec = <%=Request.Form("KeySpec")%>;
  188.       IControl.UseExistingKeySet = <%=Request.Form("UseExistingKeySet")%>;   
  189.           
  190.     <% end if %>
  191.  
  192.       szPKCS10 = IControl.CreatePKCS10(DN, document.ReqData.CertUsage.value);
  193.       document.ReqData.CertRequest.value = szPKCS10;
  194.  
  195.   <% elseif ControlType = "CERTENR3" then %>
  196.          
  197.      szSessionID=<%=Session.SessionID%>
  198.      szPKCS10 = IControl.GenerateKeyPair(szSessionID, false, DN, 0, "ClientAuth", false, true, 1);
  199.      document.ReqData.CertRequest.value = szPKCS10;
  200.      document.ReqData.PassThru.value = szSessionID;      
  201.  
  202.   <% end if %>
  203.   
  204.      if (szPKCS10 != "")
  205.        document.ReqData.submit();
  206.      else {
  207.        Msg = "The data you have entered appears to be invalid.";
  208.        alert(Msg);
  209.        window.navigate ("/certsrv/default.htm")
  210.      }
  211.    }   
  212. -->
  213.    </SCRIPT> 
  214.  
  215. <% end if %>
  216.  
  217.  
  218. <% if ControlType = "XENROLL" then %>
  219.      
  220.      <SCRIPT LANGUAGE="VBSCRIPT"> 
  221. <!--
  222.        function Adv()
  223.            
  224.          Dim CspList, CspCount, cspIndex, ProviderName
  225.          On Error Resume Next
  226.          
  227.          CspList = ""
  228.          NumOfCsps = 0
  229.          StrSize = 0
  230.          ProviderName = ""
  231.          
  232.          For ProvType = 0 to 1  
  233.            cspIndex = 0
  234.            'ProviderName = ""             
  235.            IControl.ProviderType = ProvType
  236.            ProviderName = IControl.enumProviders(cspIndex,0)
  237.         
  238.        while ProviderName <> ""          
  239.               CspList = CspList & ProvType & "*" & ProviderName & "*"
  240.               cspIndex = cspIndex +1
  241.               ProviderName = ""
  242.               ProviderName = IControl.enumProviders(cspIndex,0)
  243.                     
  244.            wend
  245.            CspCount = (CspCount +1) + (cspIndex-1) 
  246.          Next
  247.          
  248.          document.CSPFORM.CspList.value = CspList
  249.          document.CSPFORM.CspCount.value = CspCount
  250.  
  251.          document.CSPFORM.CommonName.value = document.ReqForm.CommonName.value
  252.          document.CSPFORM.Org.value = document.ReqForm.Org.value
  253.          document.CSPFORM.OrgUnit.value = document.ReqForm.OrgUnit.value
  254.          document.CSPFORM.Locality.value = document.ReqForm.Locality.value
  255.          document.CSPFORM.State.value = document.ReqForm.State.value
  256.          document.CSPFORM.Country.value = document.ReqForm.Country.value
  257.          document.CSPFORM.Email.value = document.ReqForm.Email.value
  258.      
  259.      
  260.          if CspCount = 0 then
  261.         msg = "The enrollment control did not successfully download to"
  262.         msg = msg & " your machine.  These pages require the control and will not"
  263.          msg = msg & " work correctly without it."
  264.         
  265.                 Button = MsgBox (msg, 21, "Xenroll")
  266.                 
  267.                 if Button = vbRetry then
  268.          window.navigate ("ceenroll.asp")
  269.         else
  270.          window.navigate ("/certsrv/default.htm")
  271.                 end if
  272.          else
  273.       document.CSPFORM.submit() 
  274.     end if
  275.        
  276.        end function
  277. -->
  278.        </SCRIPT>
  279.  
  280.  
  281. <% End If %>
  282.  
  283. </HEAD>
  284.  
  285.  <BODY Background="csback.gif">
  286.  <BODY BGCOLOR=#FFFFFF>
  287.  <B><A HREF="/CertSrv/default.htm">HOME</A></B>
  288.  <HR>
  289.  <IMG SRC="cslogo.gif" alt="Product Logo"> 
  290.  
  291.  
  292.  <% if ControlType = "NETSCAPE" or _
  293.       ControlType = "CERTENR3" or _
  294.       ControlType = "XENROLL" then %>
  295.  
  296.  <CENTER> 
  297.  
  298.  <FONT SIZE=6><B>Certificate Enrollment Form</B></FONT>
  299.  
  300.  <% if ControlType = "NETSCAPE" then %>
  301.   <FORM NAME="CertForm" ACTION="kgaccept.asp" ENCTYPE=x-www-form-encoded METHOD=POST>
  302.  <% else %>
  303.   <FORM NAME="ReqForm" ENCTYPE=x-www-form-encoded METHOD=POST>
  304.  <% end if%>
  305.  
  306.    <TABLE BORDER=8>
  307.    <TR>
  308.    <TH ALIGN=LEFT><B>Name:</B></TH>    
  309.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="CommonName" VALUE= "<%=Request.Form("CommonName")%>"></TD>
  310.    <TR>
  311.    <TH ALIGN=LEFT><B>Department:</B></TH>        
  312.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="OrgUnit" VALUE= "<%=Request.Form("OrgUnit")%>"></TD>
  313.    <TR>
  314.    <TH ALIGN=LEFT><B>Organization:</B></TH>    
  315.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="Org" VALUE= "<%=Request.Form("Org")%>"></TD>
  316.    <TR>
  317.    <TH ALIGN=LEFT><B>City:</B></TD>        
  318.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="Locality" VALUE= "<%=Request.Form("Locality")%>"></TD>
  319.    <TR>
  320.    <TH ALIGN=LEFT <B>State:</B></TH>    
  321.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="State" VALUE= "<%=Request.Form("State")%>"></TD>
  322.    <TR>
  323.    <TH ALIGN=LEFT <B>Country:</B></TH>        
  324.    <TD><INPUT TYPE="TEXT" MAXLENGTH="2" SIZE=42 NAME="Country" VALUE= "<%=Request.Form("Country")%>"></TD> 
  325.    <TR>
  326.    <TH ALIGN=LEFT <B>E-Mail:</B></TH>
  327.    <TD><INPUT TYPE="TEXT" MAXLENGTH="64" SIZE=42 NAME="Email" VALUE= "<%=Request.Form("Email")%>"></TD>
  328.     
  329.   <%if ControlType = "NETSCAPE" then %>
  330.      <TR>
  331.         <TH ALIGN=LEFT <B>Key Strength:</B></TH>    
  332.         <TD><KEYGEN TYPE="hidden" NAME="CertRequest" CHALLENGE="test"></TD>
  333.         </TABLE>
  334.         <BR>
  335.         <INPUT TYPE="Submit" NAME="Request" value="Submit">    
  336.         </FORM>
  337.   <% else %>
  338.    </TABLE>
  339.    </FORM>
  340.    </FONT>
  341.  
  342.   <TABLE>   
  343.    <TH ALIGN=LEFT>    
  344.    <FORM NAME="ReqData" ACTION="ceaccept.asp" ENCTYPE=x-www-form-encoded METHOD=POST>
  345.       <INPUT TYPE="HIDDEN" NAME="CertRequest">
  346.       <INPUT TYPE="HIDDEN" NAME="CertAttrib" VALUE="">
  347.       <INPUT TYPE="HIDDEN" NAME="SubmitFlag" VALUE=257>
  348.       <INPUT TYPE="HIDDEN" NAME="GetCertFlag" VALUE=257>
  349.       <INPUT TYPE="HIDDEN" NAME="ControlType" VALUE=<%=ControlType%>>
  350.       <INPUT TYPE="HIDDEN" NAME="PassThru" VALUE="ceenroll.asp">       
  351.       <INPUT TYPE="HIDDEN" NAME="CertUsage">
  352.       <INPUT TYPE="HIDDEN" NAME="WriteCertToCSP">
  353.       <INPUT TYPE="HIDDEN" NAME="SaveCert">
  354.       <INPUT TYPE="Submit" NAME="Request" value="Submit Request" onClick="SubmitRequest()">
  355.    </FORM>
  356.    </TH>
  357.  
  358.     <% if CONTROLTYPE = "XENROLL" then %>
  359.  
  360.       <TD>  
  361.       <FORM NAME="CSPFORM" ACTION="ceadv.asp" ENCTYPE=x-www-form-encoded METHOD=POST>
  362.         <INPUT TYPE="HIDDEN" NAME="CspList" VALUE="">
  363.         <INPUT TYPE="HIDDEN" NAME="CspCount" VALUE=0>
  364.         <INPUT TYPE="HIDDEN" NAME="CommonName">
  365.         <INPUT TYPE="HIDDEN" NAME="Org">
  366.         <INPUT TYPE="HIDDEN" NAME="OrgUnit">
  367.         <INPUT TYPE="HIDDEN" NAME="Locality">
  368.         <INPUT TYPE="HIDDEN" NAME="State">
  369.         <INPUT TYPE="HIDDEN" NAME="Country">
  370.         <INPUT TYPE="HIDDEN" NAME="Email">
  371.         <INPUT TYPE="Submit" NAME="Advanced" value="Advanced" OnClick="Adv()">
  372.       </FORM>    
  373.       </TD>
  374.      <% end if %>
  375.   </TABLE>
  376.  
  377.  <% end if %>   
  378.  
  379.  </CENTER>
  380.  
  381.  
  382.  <% elseif ControlType = "UNKNOWN" then %>
  383.   <CENTER>
  384.   <FONT SIZE=6><B>Please select your browser type.</B></FORM>
  385.   <B>
  386.   <BR><BR>
  387.   <FORM ACTION="ceenroll.asp" METHOD=POST>
  388.     <TABLE BORDER=8 CELLPADDING=20> 
  389.     
  390.     <TD ALIGN=CENTER>
  391.     <FONT SIZE=5>
  392.       Browser Type
  393.       <BR>
  394.       <SELECT NAME="sBrowser"> 
  395.        <OPTION SELECTED VALUE="IE4"> Microsoft Internet Explorer 4.0
  396.        <OPTION VALUE="IE4"> Microsoft Internet Explorer 3.02 with Authenticode 2.0
  397.        <OPTION VALUE="IE3"> Microsoft Internet Explorer 3.0 to 3.02
  398.        <OPTION VALUE="NETSCAPE"> Netscape
  399.       </SELECT>
  400.     <BR><BR>               
  401.     <INPUT TYPE="submit" VALUE="Submit"></TD>
  402.     </B></FONT>
  403.     </TABLE>
  404.   </FORM>
  405.   </CENTER>
  406.  
  407.  <% else %>
  408.  
  409.   <CENTER>
  410.   <H1>Error!!!</H1>
  411.   <B>
  412.   <FONT SIZE=5>
  413.   Your browser does not appear to meet the requirments for Certificate Enrollment.
  414.   </FONT>
  415.   <FONT SIZE=5> 
  416.   <BR><BR><BR>
  417.   Please upgrade your browser to latest version of Microsoft Internet Explorer.
  418.   </FONT>
  419.   </B>    
  420.   <BR><BR><BR><BR> 
  421.   </CENTER>
  422.  
  423.  <% end if %>
  424.  
  425.  
  426.   <!--FOOTER START-->
  427.   <HR>
  428.   <HR>
  429.   <i>© 1997 by Microsoft Corporation. All rights reserved.</i>
  430.   <!--FOOTER END-->
  431.  
  432. </BODY>
  433. </HTML>
  434.  
  435.  
  436.  
  437.