ICertAdmin::SetRequestAttributes method (certadm.h)
The SetRequestAttributes method sets attributes in the specified pending certificate request. This method was first defined in the ICertAdmin interface.
For this method to succeed, the certificate request must be pending.
Syntax
HRESULT SetRequestAttributes(
[in] const BSTR strConfig,
[in] LONG RequestId,
[in] const BSTR strAttributes
);
Parameters
[in] strConfig
Represents a valid configuration string for the certification authority (CA) server in the form COMPUTERNAME\CANAME, where COMPUTERNAME is the network name of the Certificate Services server and CANAME is the common name of the certification authority, as entered during Certificate Services setup. For information about the configuration string name, see ICertConfig.
[in] RequestId
Specifies the ID of the request receiving the attributes.
[in] strAttributes
Specifies the attribute data. Each attribute is a name-value string pair. The colon character separates the name and value, and a newline character separates multiple name-value pairs, for example:
C++ | AttributeName1:AttributeValue1\nAttributeName2:AttributeValue2 |
VB | AttributeName1:AttributeValue1 & vbNewLine & AttributeName2:AttributeValue2 |
When Certificate Services parses attribute names, it ignores spaces, hyphens (minus signs), and case. For example, AttributeName1, Attribute Name1, and Attribute-name1 are all equivalent. For attribute values, Certificate Services ignores leading and trailing white space.
Return value
VB
If the method succeeds, the method returns S_OK.If the method fails, it returns an HRESULT value that indicates the error. For a list of common error codes, see Common HRESULT Values.
Remarks
Attributes added or updated by calling SetRequestAttributes do not alter the initial, unparsed attribute string associated with the certificate request. The certificate request's unparsed attribute string is unalterable after the certificate is requested (the ICertRequest::Submit method allows attributes to be specified at the time the certificate is requested).
You can use the Certification Authority MMC snap-in to display the initial unparsed request attribute string.
When you view the parsed attributes, you will also see any changes due to calls to SetRequestAttributes.
To view the parsed attributes
- Open the Certification Authority MMC snap-in.
- Open the Pending Requests folder.
- Right-click a request, point to All Tasks, and then click View Attributes/Extensions.
Administration tasks use DCOM. Code that calls this interface method as defined in an earlier version of Certadm.h will run on Windows-based servers as long as the client and the server are both running the same Windows operating system.
Examples
BSTR bstrAttribs = NULL;
BSTR bstrCA = NULL;
long nReqID; // request ID
// Specify the attributes.
// For example, "AttName1:AttValue1\nAttName2:AttValue2".
bstrAttribs = SysAllocString(L"<ATTRIBUTESHERE>");
if (NULL == bstrAttribs)
{
printf("Memory allocation failed for bstrAttribs.\n");
goto error;
}
bstrCA = SysAllocString(L"<COMPUTERNAMEHERE>\\<CANAMEHERE>");
if (NULL == bstrCA)
{
printf("Memory allocation failed for bstrCA.\n");
goto error;
}
// Request ID to receive the attributes.
nReqID = <REQUESTIDHERE>;
// Add these attributes to the certificate.
// pCertAdmin is a previously instantiated
// ICertAdmin object pointer.
hr = pCertAdmin->SetRequestAttributes( bstrCA,
nReqID,
bstrAttribs );
if (FAILED(hr))
printf("Failed SetRequestAttributes [%x]\n", hr);
else
printf("SetRequestAttributes succeeded\n");
// Done processing.
error:
if (bstrAttribs)
SysFreeString(bstrAttribs);
if (bstrCA)
SysFreeString(bstrCA);
// Free other resources.
Requirements
Requirement | Value |
---|---|
Minimum supported client | None supported |
Minimum supported server | Windows Server 2003 [desktop apps only] |
Target Platform | Windows |
Header | certadm.h (include Certsrv.h) |
Library | Certidl.lib |
DLL | Certadm.dll |