共用方式為


<basicHttpBinding> 的 <transport>

定義可控制 HTTP 傳輸之驗證參數的屬性。

<configuration>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding>
          <security>
            <transport>

Syntax

<basicHttpBinding>
  <binding>
    <security mode="None|Transport|Message|TransportWithMessageCredential|TransportCredentialOnly">
      <transport clientCredentialType="None|Basic|Digest|Ntlm|Windows"
                 proxyCredentialType="None|Basic|Digest|Ntlm|Windows"
                 realm="String">
        <extendedProtectionPolicy policyEnforcement="Never|WhenSupported|Always"
                                  protectionScenario="TransportSelected|TrustedProxy">
          <customServiceNames>
          </customServiceNames>
        </extendedProtectionPolicy>
      </transport>
    </security>
  </binding>
</basicHttpBinding>

屬性和項目

下列章節說明屬性、子元素和父元素。

屬性

屬性 描述
clientCredentialType - 指定當使用 HTTP 驗證執行用戶端驗證時,要使用的認證類型。 預設值為 None。 此屬性的型別為 HttpClientCredentialType
proxyCredentialType - 指定當使用 Proxy over HTTP 從網域內執行用戶端驗證時,要使用的認證類型。 這個屬性僅適用於父 mode 項目的 security 屬性是 TransportTransportCredentialsOnly 時。 此屬性的型別為 HttpProxyCredentialType
realm 字串,指定摘要式驗證或基本驗證的 HTTP 驗證配置所使用的領域。 預設為空字串。
policyEnforcement 此列舉指定了應該強制執行 ExtendedProtectionPolicy 的時間。

1. Never:絕不強制執行此原則 (已停用延伸保護)。
2. WhenSupported - 只有當用戶端支援延伸保護時,才施行此原則。
3.Always:一律強制執行此原則。 不支援延伸保護的用戶端將無法驗證。
protectionScenario 此列舉會指定原則強制執行的保護案例。

clientCredentialType 屬性

描述
傳輸期間不會保護訊息的安全。
基本 指定基本驗證。
Digest 指定摘要式驗證。
Ntlm 指定可能的情況下以及 Windows 驗證失敗時的 NTLM 驗證。
Windows 指定 Windows 整合式驗證。

proxyCredentialType 屬性

描述
- 傳輸期間不會保護訊息的安全。
基本 指定依照 RFC 2617 – HTTP Authentication: Basic and Digest Authentication 所定義的基本驗證。
Digest 指定依照 RFC 2617 – HTTP Authentication: Basic and Digest Authentication 所定義的摘要式驗證。
Ntlm 指定可能的情況下以及 Windows 驗證失敗時的 NTLM 驗證。
Windows 指定 Windows 整合式驗證。
憑證 使用憑證執行用戶端驗證。 這個選項只有在父 Mode 項目的 security 屬性設為 Transport 時才能使用,如果該屬性設為 TransportCredentialOnly,則無法使用。

子元素

父項目

元素 描述
<security> 定義 <basicHttpBinding> 的安全性功能。

範例

下列範例示範透過基本繫結來使用 SSL 傳輸安全性。 根據預設,基本繫結支援 HTTP 通訊。

<system.serviceModel>
  <services>
    <service type="Microsoft.ServiceModel.Samples.CalculatorService"
             behaviorConfiguration="CalculatorServiceBehavior">
      <endpoint address=""
                binding="basicHttpBinding"
                bindingConfiguration="Binding1"
                contract="Microsoft.ServiceModel.Samples.ICalculator" />
    </service>
  </services>
  <bindings>
    <basicHttpBinding>
      <!-- Configure basicHttpBinding with Transport security -->
      <!-- mode and clientCredentialType set to None. -->
      <binding name="Binding1">
        <security mode="Transport">
          <transport clientCredentialType="None"
                     proxyCredentialType="None">
            <extendedProtectionPolicy policyEnforcement="WhenSupported"
                                      protectionScenario="TransportSelected">
              <customServiceNames>
              </customServiceNames>
            </extendedProtectionPolicy>
          </transport>
        </security>
      </binding>
    </basicHttpBinding>
  </bindings>
</system.serviceModel>

另請參閱