Microsoft Internet Security and Acceleration Server 2000

Assign a Client Certificate to a Publishing Rule

The following VBScript code example assigns a client certificate to a publishing rule.

Example

call Install


Sub Install
		Set fpc = CreateObject("FPC.Root")
		Set CurServer = fpc.Arrays(1).Servers(1)
		NL = Chr(13) & Chr(10)
		TAB = Chr(9)
		Set certs = CurServer.SSLClientCertificates
		Dim i
		i = 1
		Dim certificates
		certificates = ""
		For Each cert In certs
			certificates = certificates & _
				i & ":" & TAB & cert.FriendlyName & NL & _
						TAB & cert.IssuedTo & NL & _
						TAB & cert.IssuedBy & NL & _
						TAB & cert.ExpirationDate & NL & NL 
			i = i + 1
		Next

		Dim n

		n = InputBox(certificates & "Which certificate do you choose?", "Choose A Client Certificate")

		if not n > 0 and n < i then
				MsgBox "You chose a wrong number (" & n & ")" & NL & _
					 "Choose a number between 1 and " & i - 1
				Exit Sub
		end if

		Set cert = CurServer.SSLClientCertificates(n)

		MsgBox "You chose " & n & ":" & NL & _
			 "Friendly Name:" & TAB & cert.FriendlyName & NL &_
			 "Issued To:"	 & TAB & cert.IssuedTo & NL & _
			 "Issued By:"	 & TAB & cert.IssuedBy & NL & _
			 "Expires at:"	& TAB & cert.ExpirationDate 

		Set rules = fpc.Arrays(1).Publishing.WebPublishingRules
	
		i = 1
		Dim PubRules 
		PubRules = ""
		For each rule in rules
			PubRules = PubRules & _ 
				i & ":" & TAB & rule.Name & NL & NL
			i = i + 1
		Next

		n = InputBox(PubRules & "Which publish rule do you choose?", "Choose a publish rule")
		if not n > 0 and n < i - 2 then
				MsgBox "You chose a wrong number (" & n & ")" & NL & _
					 "Choose a number between 1 and " & i - 2
				Exit Sub
		end if

		Set rule = fpc.Arrays(1).Publishing.WebPublishingRules(CInt(n))

		MsgBox "You chose " & m & ":" & NL & _
			 "Name:" & TAB & rule.Name

		rule.SSLClientCertificate = cert
		rule.Save

		MsgBox "done"

End sub