Source code of Windows XP (NT5)
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.

84 lines
2.2 KiB

  1. <% @ LANGUAGE = VBScript %>
  2. <% Option Explicit %>
  3. <% Response.Buffer= true %>
  4. <HTML>
  5. <HEAD>
  6. <title>Create New Certificate Mapping</title>
  7. <%
  8. Dim objW3svr, objCertMapper, vntCertificate, vntAccnt, vntPassword, strMapName, bEnabled
  9. vntAccnt = Request.form("AccountName")
  10. vntPassword = Request.form("Password")
  11. strMapName = Request.form("MapName")
  12. If Request.form("Enablemap")="true" then
  13. bEnabled = true
  14. Else
  15. bEnabled = false
  16. End If
  17. If vntAccnt <>"" Then
  18. Err.Clear
  19. On Error Resume Next
  20. vntCertificate = Request.ClientCertificate("CERTIFICATE")
  21. If vntCertificate = "" Then
  22. Response.Write "No cert is presented <BR>"
  23. End If
  24. Set objW3svr = GetObject("IIS://localhost/W3svc/1")
  25. If Err.Number<>0 Then
  26. Response.Write "Function GetObject failed!<BR>"
  27. Response.End
  28. End If
  29. Set objCertMapper = objW3svr.GetObject("IISCertMapper", "MyCertMapper")
  30. 'if failed, try to create new IISCertMapper Object
  31. If Err.number<>0 then
  32. Err.clear
  33. Set objCertMapper = objW3svr.Create("IISCertMapper", "MyCertMapper")
  34. If Err.Number <>0 Then
  35. Response.Write "Could not create IISCertMapper object!<BR>"
  36. Response.End
  37. Else
  38. 'objCertMapper.SetInfo
  39. objW3svr.SetInfo
  40. End if
  41. End If
  42. objCertMapper.CreateMapping vntCertificate, vntAccnt, vntPassword, strMapName, bEnabled
  43. If Err.number <>0 Then
  44. Response.Write "Mapping Failed <BR> See following instruction<BR>"
  45. Else
  46. Response.Write "You have succeded to create a new mapping <BR>"
  47. End If
  48. Set objCertMapper=Nothing
  49. Set objW3svr = Nothing
  50. End If
  51. %>
  52. </HEAD>
  53. <BODY>
  54. For this sample to work properly, You need to do following: <BR>
  55. 1.Require SSL to access this asp page. <BR>
  56. 2.Require client certificate.<BR>
  57. 3.uncheck anonymous authentication. <BR>
  58. 4.install client certificate into your browser. <BR>
  59. <FORM action=Setcertmapping.asp method=post>
  60. <P> Account Name to map
  61. <BR><INPUT TYPE=TEXT NAME="AccountName" >
  62. <P> Password
  63. <BR> <INPUT TYPE="PASSWORD" Name="Password" >
  64. <P> Mapping Name
  65. <BR> <INPUT TYPE="TEXT" Name="MapName" >
  66. <P> Enable mapping
  67. <BR><Select name="EnableMap">
  68. <Option value="true"> True
  69. <Option value="false"> False
  70. </Select>
  71. <P>
  72. <INPUT TYPE="SUBMIT" value="Submit"><INPUT TYPE="RESET" value="RESET">
  73. </FORM>
  74. </BODY>
  75. </HTML>