home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 9 / IOPROG_9.ISO / contrib / iis4 / certsrv.cab / ceaccept.asp next >
Encoding:
Text File  |  1997-08-25  |  5.1 KB  |  207 lines

  1. <%Response.Expires=0%>
  2. <HTML>
  3. <HEAD>
  4. <TITLE>Web Server Enrollment Page</TITLE>
  5. <META HTTP-EQUIV="Cache-Control" CONTENT="no cache">
  6. <META HTTP-EQUIV="Pragma" CONTENT="no cache">
  7. <META HTTP-EQUIV="Expires" CONTENT="0">
  8.  
  9.  
  10. <% 
  11.     ''Process a Certificate Request
  12.     
  13.     On Error Resume Next
  14.     
  15.     Dim Certificate, DispositionCode, LastStatus,ConfigString, PKCS10         
  16.     Dim SubmitFlag, GetCertFlag, Attributes, ControlType, CPUType  
  17.             
  18.     set ICertRequest = Server.CreateObject("CertificateAuthority.Request")
  19.     set ICertConfig     = Server.CreateObject("CertificateAuthority.Config") 
  20.  
  21.     ConfigString = ICertConfig.GetConfig(0)
  22.     PKCS10         = Request.Form("RequestData")
  23.     SubmitFlag   = Request.Form("SubmitFlag")
  24.     GetCertFlag  = Request.Form("GetCertFlag")
  25.     Attributes   = Request.Form("CertAttrib")
  26.     ControlType  = Request.Form("ControlType")
  27.        
  28.         DispositionCode = ICertRequest.Submit(SubmitFlag, PKCS10, Attributes, ConfigString)
  29.     
  30.     LastStatus = 0
  31.     LastStatus = ICertRequest.GetLastStatus()
  32.     Certificate = ICertRequest.GetCertificate(GetCertFlag)
  33.     
  34.     Session("CertStore") = Certificate               
  35. %>
  36.  
  37.  
  38. <% if ControlType = "" then %>
  39.     <SCRIPT LANGUAGE="JAVASCRIPT">
  40.         function Download() {
  41.             window.location = "newcert.cer";    
  42.         }
  43.     </SCRIPT>
  44.  
  45. <% else
  46.  
  47.      ''Format the Certificate
  48.  
  49.      FormatedCert = ""
  50.      qc = chr(34)
  51.      CharsLeft = True
  52.      OutP = 1
  53.  
  54.      while(CharsLeft)
  55.     BeginLine = OutP
  56.     OutP = InStr(OutP, Certificate, vbNewLine)
  57.  
  58.     if (OutP > 0) then
  59.        FormatedCert = FormatedCert & "szPKCS7 = szPKCS7 & " & qc & _
  60.        Mid(Certificate, BeginLine, OutP-BeginLine) & qc 
  61.  
  62.            if (OutP >= (len(Certificate) - len(vcNewLine))) then 
  63.          CharsLeft = False
  64.        end if
  65.     
  66.     else
  67.       CharsLeft = False
  68.     end if
  69.       FormatedCert = FormatedCert & vbNewLine
  70.       OutP = OutP + len(vbNewLine)
  71.      wend
  72.  
  73. end if %>
  74.      
  75.   
  76. <% if ControlType = "XENROLL" or ControlType = "CERTENR3" then %>     
  77.  
  78.     <% if ControlType = "XENROLL" then %>
  79.       <OBJECT
  80.        classid="clsid:43F8F289-7A20-11D0-8F06-00C04FC295E1"
  81.        CODEBASE="/CertControl/<%=Request.Form("CPUType")%>/xenroll.dll"
  82.        id=IControl
  83.       >
  84.       </OBJECT>   
  85.     <% else %>
  86.       <OBJECT
  87.         classid="clsid:33BEC9E0-F78F-11cf-B782-00C04FD7BF43"
  88.         CODEBASE="/CertControl/x86/certenr3.dll"
  89.         id=IControl
  90.       >
  91.       </OBJECT>
  92.     <% end if %>  
  93.  
  94.    <SCRIPT LANGUAGE="VBSCRIPT">
  95.    sub Download() 
  96.  
  97.     Dim result, Message
  98.         
  99.         On Error Resume Next
  100.         
  101.     szPKCS7 = ""
  102.         <%=FormatedCert%>
  103.       
  104.    <% if StrComp(ControlType, "XENROLL", 1) = 0 then %> 
  105.         IControl.AcceptPKCS7(szPKCS7)
  106.    <% else %>
  107.         szSessionID = "<%=Request.Form("PassThru") %>"
  108.         Result = IControl.AcceptCredentials(szSessionID, szPKCS7, 0, FALSE)
  109.    <% end if %>
  110.         If err.Number = 0 Then
  111.    <% if ControlType = "XENROLL" then %>
  112.           Message = "Your new certificate has been successfully installed. " & vbcrlf & vbcrlf
  113.           Message = Message & " If you are using IE3.02 or IE4.0 Preview 2 and you"
  114.           Message = Message & " have not already installed this Certificate"
  115.           Message = Message & " Authority's Root Certificate, you must do so from the"
  116.           Message = Message & " 'Install Certificate Authority Certificates'"
  117.           Message = Message & " page."
  118.           result = MsgBox (Message, 0, "Certificate Server")
  119.       window.location = "default.htm"
  120.    <% else %>
  121.           Message = "Your new certificate has been successfully installed."
  122.           result = MsgBox (Message, 0, "Certificate Server")
  123.       window.location = "default.htm"
  124.    <% end if %>    
  125.         Else
  126.           Message = "Unable to install the certificate." & _
  127.                      vbNewLine & vbNewLine & "Error: " & Hex(err)
  128.       result = MsgBox (Message, 48, "<%=ControlType%>")  
  129.     End If    
  130.    end sub 
  131.    </SCRIPT>
  132.  
  133. <% end if %>
  134.  
  135.  
  136. <Body Background="csback.gif">
  137. <BODY BGCOLOR=#FFFFFF>
  138. <B><A HREF="../default.htm">HOME</A></B>
  139. <HR>
  140.  
  141. <UL><IMG SRC="cslogo.gif" ALIGN="MIDDLE" border=0 alt="Product Logo"></UL>
  142.  
  143. <Center>
  144.     
  145. <%  if DispositionCode = 3 then %>
  146.  
  147.       <H1>Certificate Download</H1>
  148.       <B>
  149.       <FONT SIZE=5>
  150.       <BR>Your request has been successfully processed!
  151.       </FONT>
  152.       <FONT SIZE=4>  
  153.       <BR><BR><BR><BR><BR>Please click the Download button to obtain your new certificate.
  154.       <BR><BR>
  155.       </FONT>
  156.       <FORM>
  157.          <INPUT TYPE=BUTTON VALUE="Download" NAME="Certificate" OnClick="Download()">    
  158.       </FORM>
  159.       <BR><BR><BR><BR><BR>
  160.  
  161. <%  else %>
  162.  
  163.       <H1>Error!!!</H1>
  164.       <B>
  165.       <FONT SIZE=5>
  166.       
  167.       Certificate Server is unable to process your request.
  168.       </FONT>
  169.       <BR><BR><BR>
  170.       <FONT SIZE=4>
  171.       <I>
  172.       Last Status Error Code = <%=LastStatus%>
  173.       </I>
  174.       </FONT>   
  175.           <FONT SIZE=5> 
  176.       <BR><BR><BR>
  177.           Please insure that you are submiting a valid request or contact 
  178.       <BR>your Certificate Authority for assistance.
  179.       </FONT>
  180.       </B>    
  181.           <BR><BR><BR><BR> 
  182.  
  183. <%  end if %>
  184.  
  185. </CENTER>
  186.  
  187. <!--FOOTER START-->
  188. <HR>
  189. <HR>
  190. <FORM>
  191. <i>© 1997 by Microsoft Corporation. All rights reserved.</i>
  192. </FORM>
  193. <!--FOOTER END-->
  194.     
  195.  
  196. </BODY>
  197. </HTML>
  198.  
  199.  
  200.  
  201.     
  202.         
  203.     
  204.         
  205.  
  206.         
  207.