Re: Smart Card Login fails after renewal
From: aelkins (anonymous_at_discussions.microsoft.com)
Date: 05/27/04
- Next message: Rhett Gong [MSFT]: "Re: Secure dynamic updates on Windows 2003 DNS Server"
- Previous message: Eduard Koller [MSFT]: "Re: how to use Cryto API"
- In reply to: Vishal Agarwal[MSFT]: "Re: Smart Card Login fails after renewal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Date: Wed, 26 May 2004 19:31:03 -0700
Here is the code
Const CAPICOM_MEMORY_STORE = 0
Const CAPICOM_LOCAL_MACHINE_STORE = 1
Const CAPICOM_CURRENT_USER_STORE = 2
Const CAPICOM_ACTIVE_DIRECTORY_USER_STORE = 3
Const CAPICOM_SMART_CARD_USER_STORE = 4
Const CAPICOM_STORE_OPEN_READ_WRITE = 1
Const CR_IN_BASE64 = &H1
Const CR_IN_PKCS10 = &H100
Const CR_out_BASE64HEADER = 0
Const CR_out_CHAIN = &H100
Const SmartCardProviderName = "Schlumberger Cryptographic Service Provider"
Const CertServer = "Server1"
Set CurrentUserStore = CreateObject("CAPICOM.Store")
Set SmartCardStore = CreateObject("CAPICOM.Store")
SmartCardStore.Open CAPICOM_SMART_CARD_USER_STORE, "MY", CAPICOM_STORE_OPEN_READ_WRITE
CurrentUserStore.Open CAPICOM_SMART_CARD_USER_STORE, "MY", CAPICOM_STORE_OPEN_READ_WRITE
' Note: I know there is only one cert in the CurrentUserStore and SmartCardStore
For Each Certificate in SmarCardStore.Certificates
SmartCardUserSubjectName = Certificate.SubjectName
SmarCardCertificateTemplateName = Certificate.Template.Name
SmarCardCertificateTemplateOID = Certificate.Template.OID
SmartCardSimpleName = Certificate.GetInfo(0)
Next
' Remove Certificates for CurrentUser and SmartCard
For Each Certificate in CurrentUserStore.Certificates
CurrentUserStore.Remove Certificate
Next
For Each Certificate in SmartCardStore.Certificates
Certificate.PrivateKey.Delete
Certificate.PrivateKey = Nothing
Next
Set Enroll = CreateObject("CEnroll.CEnroll.2")
Enroll.addCertTypeToRequest = SmarCardCertificateTemplateName
Enroll.ProviderName = SmartCardProviderName
Enroll.UserExistingKeySet = FALSE
strReq = Enroll.createPKCS10( SmartcardUserSubjectName, SmartcardCertificateTemplateOID)
Set CertRequest = CreateObject("CertificateAuthority.Request")
nDisp = CertRequest.Submit (CR_IN_BASE64 or CR_IN_PKCS10, strReq, "", CertServer & "\" &
_SmartCardSimpleName)
ID = CertRequest.GetRequestID
Cert = CertRequest.GetCertificate (CR_OUT_BASE64HEADER or CR_OUT_CHAIN)
Enroll.acceptResponse Cert
- Next message: Rhett Gong [MSFT]: "Re: Secure dynamic updates on Windows 2003 DNS Server"
- Previous message: Eduard Koller [MSFT]: "Re: how to use Cryto API"
- In reply to: Vishal Agarwal[MSFT]: "Re: Smart Card Login fails after renewal"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|