Platform SDK: Certificate Enrollment Control

ICEnroll::WriteCertToCSP [C++]

CEnroll.WriteCertToCSP [Visual Basic]

The WriteCertToCSP property specifies whether a certificate should be written to the cryptographic service provider (CSP). This is typically used with smart cards, where the certificate is written to the smart card in addition to being written to the "MY" store.

The default value is TRUE, meaning that the Certificate Enrollment Control will try to write the certificate to the CSP; but will not fail unless a hardware token error is encountered. (If this value is TRUE, but no smart card or other hardware-dependent CSP is installed, then hardware token errors will be ignored).

To explicitly force that the Certificate Enrollment Control not attempt to write to the CSP, set this value to FALSE.

[Visual Basic]
objEnroll.WriteCertToCSP [ = bValue ]
[C++]
HRESULT put_WriteCertToCSP(BOOL bValue);
HRESULT get_WriteCertToCSP(BOOL * pbValue);

Parameters

[Visual Basic] objEnroll
Object expression that resolves to a CEnroll object.
[Visual Basic,C++] bValue
A boolean value assigned to the WriteCertToCSP property. It is one of the following values:
[C++] pbValue
Pointer to retrieved property value.

Remarks

WriteCertToCSP affects the behavior of the following methods:

Example Code [C++]

BOOL     bWriteCSP;
HRESULT  hr;

// pEnroll is previously instantiated ICEnroll interface pointer

// get the WriteCertToCSP value
hr = pEnroll->get_WriteCertToCSP( &bWriteCSP );
if (FAILED( hr ))
    printf("Failed get_WriteCertToCSP - %x\n", hr );
else
    printf( "WriteCertToCSP: %d\n", bWriteCSP );

// set the WriteCertToCSP value
hr = pEnroll->put_WriteCertToCSP( TRUE );
if (FAILED( hr ))
    printf("Failed put_WriteCertToCSP - %x\n", hr );
else
    printf( "WriteCertToCSP set to TRUE\n" ); 

Example Code [Visual Basic]

' declare Certificate Enrollment Control object
Dim objXen As Object

Dim bWriteCSP As Boolean

' instantiate the object
Set objXen = CreateObject("CEnroll.CEnroll.1")

' retrieve and display the WriteCertToCSP value
bWriteCSP = objXen.WriteCertToCSP
MsgBox bWriteCSP, vbOKOnly, "WriteCertToCSP"

' set the WriteCertToCSP value
objXen.WriteCertToCSP = True

Requirements

  Windows NT/2000: Requires Windows 2000 (or Windows NT 4.0 with the Windows NT 4.0 Option Pack).
  Header: Declared in Xenroll.h.
  Library: Use Uuid.lib.