IX509AttributeClientId::InitializeEncode method (certenroll.h)

The InitializeEncode method initializes the attribute from information about the user, client computer, and application that submitted the certificate request.

Syntax

HRESULT InitializeEncode(
  [in]           RequestClientInfoClientId ClientId,
  [in, optional] BSTR                      strMachineDnsName,
  [in, optional] BSTR                      strUserSamName,
  [in, optional] BSTR                      strProcessName
);

Parameters

[in] ClientId

A RequestClientInfoClientId enumeration value that identifies the type of application that created the request. Examples include auto-enrollment services, command-line request tools, and custom request applications.

[in, optional] strMachineDnsName

A BSTR variable that contains the Domain Name System (DNS) name of the computer on which the request was created, for example ComputerName.contoso.com. If you do not supply a name, the method calls the GetComputerNameEx function. If a name cannot be found, the method fails.

[in, optional] strUserSamName

A BSTR variable that contains the Security Accounts Manager (SAM) name for the user in the form DomainName\UserName. If you do not supply a name, the method calls the GetUserNameEx function. If a name cannot be found, the method fails.

[in, optional] strProcessName

A BSTR variable that contains the name of the application that created the certificate request. If you do not supply a name, the method calls the GetCommandLine function and parses the command line. If a name cannot be found, the method fails.

Return value

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.

Remarks

The object identifier (OID) for this attribute is XCN_OID_REQUEST_CLIENT_INFO (1.3.6.1.4.1.311.21.20). For more information, see CERTENROLL_OBJECTID. The attribute is created as an Abstract Syntax Notation One (ASN.1) structure that is encoded by using Distinguished Encoding Rules (DER).

You must call either InitializeEncode or InitializeDecode before you can use an IX509AttributeClientId object. The two methods complement each other. The InitializeEncode method enables you to construct an encoded ASN.1 structure from raw data, and the InitializeDecode method enables you to initialize raw data from an encoded ASN.1 structure. You can call the following properties to retrieve the raw data:

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

IX509AttributeClientId

InitializeDecode