ICertServerPolicy::GetRequestAttribute 方法 (certif.h)

GetRequestAttribute 方法會從要求傳回具名屬性

語法

HRESULT GetRequestAttribute(
  [in]  const BSTR strAttributeName,
  [out] BSTR       *pstrAttributeValue
);

參數

[in] strAttributeName

要擷取之屬性的名稱。

[out] pstrAttributeValue

將包含屬性值的 BSTR 值的指標。

傳回值

C++

如果方法成功,方法會傳回 S_OK,而 *pstrAttributeValue 會設定為包含屬性值的 BSTR

若要使用此方法,請建立 BSTR 類型的變數、將變數設定為 NULL,並將此變數的位址傳遞為 pstrAttributeValue

當您完成 使用 BSTR 時,請呼叫 SysFreeString 函式來釋放它。

如果方法失敗,它會傳回指出錯誤的 HRESULT 值。 如需常見錯誤碼的清單,請參閱 一般 HRESULT 值

VB

傳回值是表示屬性值的字串。

備註

您必須先呼叫 ICertServerPolicy::SetContext ,才能使用此方法。

下列要求屬性對 KEYGEN 樣式要求而言是唯一的。

屬性名稱 類型 Description
挑戰 字串 要求隨附的挑戰字串。
ExpectedChallenge 字串 如果挑戰字串不正確,則伺服器會將此要求屬性的值設定為預期的挑戰,以便診斷失敗。
 

範例

BSTR     bstrAttribValue = NULL;
HRESULT  hr;

// Get the request attribute.
// bstrAttribName is BSTR assigned by EnumerateAttributes.
// pCertServerPolicy has been used to call SetContext previously.
hr = pCertServerPolicy->GetRequestAttribute(bstrAttribName,
                                            &bstrAttribValue);

if (FAILED(hr))
{
    printf("Failed GetRequestAttribute [%x]\n", hr);
    goto error;
}
else
{

    // Successful call. Use the bstrAttribValue as needed.
    // ...
}

// Done processing. Free BSTR.
if (NULL != bstrAttribValue)
    SysFreeString(bstrAttribValue);

規格需求

需求
最低支援的用戶端 都不支援
最低支援的伺服器 Windows Server 2003 [僅限桌面應用程式]
目標平台 Windows
標頭 certif.h (包含 Certsrv.h)
程式庫 Certidl.lib
Dll Certcli.dll

另請參閱

ICertServerPolicy

ICertServerPolicy::SetContext