IX509CertificateRequestPkcs10::InitializeFromTemplateName method (certenroll.h)

The InitializeFromTemplateName method initializes the certificate request by using a template.

Syntax

HRESULT InitializeFromTemplateName(
  [in] X509CertificateEnrollmentContext Context,
  [in] BSTR                             strTemplateName
);

Parameters

[in] Context

An X509CertificateEnrollmentContext enumeration value that specifies whether the requested certificate is intended for an end user, a computer, or administrator acting on behalf of the computer.

[in] strTemplateName

A BSTR variable that contains the Common Name (CN) of the template as it appears in Active Directory or the dotted decimal object identifier.

Return value

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. Possible values include, but are not limited to, those in the following table. For a list of common error codes, see Common HRESULT Values.

Return code/value Description
HRESULT_FROM_WIN32(ERROR_ALREADY_INITIALIZED)
The certificate request object has already been initialized.

Remarks

The InitializeFromTemplateName method creates the following collections:

  • An ICryptAttributes collection.
  • An IX509Extensions collection.
  • An IObjectIds collection populated with the default XCN_OID_KEY_USAGE and XCN_OID_BASIC_CONSTRAINTS2 object identifiers.
  • An empty IObjectIds collection for attribute and extension OIDs to be suppressed from the new request.

The method then examines the template and performs the following actions:

If the CSPInformations property is NULL, the method creates an ICspInformations collection from the providers installed on the computer.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header certenroll.h
DLL CertEnroll.dll

See also

IX509CertificateRequestPkcs10