MessageSecurityOverHttp.NegotiateServiceCredential 屬性

定義

取得或設定值,這個值會指定是否在超出範圍的用戶端提供服務認證,或透過交涉處理從服務取得服務認證。

public:
 property bool NegotiateServiceCredential { bool get(); void set(bool value); };
public bool NegotiateServiceCredential { get; set; }
member this.NegotiateServiceCredential : bool with get, set
Public Property NegotiateServiceCredential As Boolean

屬性值

Boolean

如果服務認證是透過交涉處理取得,則為 true,否則為 false。 預設為 true

範例

下列程式碼示範如何存取及設定這個屬性。

WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType =
    MessageCredentialType.UserName;
binding.Security.Message.NegotiateServiceCredential = false;

CalculatorClient CalculatorClient = new CalculatorClient("myBinding");
CalculatorClient.ClientCredentials.ServiceCertificate.
    SetDefaultCertificate("Al", StoreLocation.CurrentUser, StoreName.My);
Dim binding As New WSHttpBinding()
binding.Security.Mode = SecurityMode.Message
binding.Security.Message.ClientCredentialType = _
MessageCredentialType.UserName
binding.Security.Message.NegotiateServiceCredential = False

Dim CalculatorClient As New CalculatorClient("myBinding")
CalculatorClient.ClientCredentials.ServiceCertificate. _
    SetDefaultCertificate("Al", StoreLocation.CurrentUser, StoreName.My)

備註

若要將此屬性設定為 true,則用戶端和服務必須支援 WS-Trust 與 WS-SecureConversation。 將這個屬性設定為 false 並不需要支援 WS-Trust 或 WS-SecureConversation。

如果是 Anonymous、Username 或 Certificate 用戶端認證類型,將這個屬性設為 false 意指服務憑證必須可在超出範圍的用戶端使用,而且用戶端必須指定要使用的服務憑證。

如果是 Windows 認證,將這個屬性設定為 false 會執行以 KerberosToken 為基礎的驗證。 這需要用戶端和服務都是 Kerberos 網域的一部分。 這個模式可與從 OASIS 實作 Kerberos 權杖設定檔的 SOAP 堆疊互通。 將這個屬性設定為 true 會進行 SOAP 訊息交涉,這項交涉會透過 SOAP 訊息傳送 SPNego 交換。 這個模式無法互通。

這個屬性會指出服務認證是否會自動在用戶端和服務之間進行交涉。 如果此屬性為 true,則會發生此種交涉。 如果這個屬性是 false,則必須先在用戶端指定服務認證,才能與服務進行通訊。

如果這個屬性設定為 false,且繫結設定為使用 Windows 做為用戶端認證型別,服務帳戶就必須與服務主要名稱 (Service Principal Name,SPN) 產生關聯。 如果要這樣做,請在 NETWORK SERVICE 帳戶或 LOCAL SYSTEM 帳戶下執行服務。 或者,使用 SetSpn.exe 工具來建立服務帳戶的 SPN。 不論是哪一種情況,用戶端都必須在servicePrincipalName > 元素中使用正確的 SPN < ,或使用 建 EndpointAddress 構函式。 如需詳細資訊,請參閱 服務識別和驗證

適用於