語言

HttpTransportBindingElement.AuthenticationScheme 屬性

定義

取得或設定用於驗證 HTTP 監聽器處理的客戶端請求的驗證方案。

public:
 property System::Net::AuthenticationSchemes AuthenticationScheme { System::Net::AuthenticationSchemes get(); void set(System::Net::AuthenticationSchemes value); };
public System.Net.AuthenticationSchemes AuthenticationScheme { get; set; }
member this.AuthenticationScheme : System.Net.AuthenticationSchemes with get, set
Public Property AuthenticationScheme As AuthenticationSchemes

屬性值

列舉中指定用於用戶端驗證的協定的列舉值 AuthenticationSchemes 之一。 預設值為 Anonymous。

例外狀況

這個價值 AuthenticationSchemes 已經設定好了。

範例

以下範例將此屬性設定為驗證客戶端請求時使用。

[ServiceContract]
interface ICalculator
{
     [OperationContract]
            Int Add(int a, int b);
}

HttpTransportBindingElement httpBinding = new HttpTransportBindingElement();
httpBinding.AuthenticationScheme = AuthenticationSchemes.Digest;
CustomBinding binding = new CustomBinding(new TextMessageEncodingBindingElement(), httpBinding);

EndpointAddress endpoint = new EndpointAddress(address);
ChannelFactory<ICalculator> proxy = new ChannelFactory<ICalculator>(binding, endpoint);

proxy.Credentials.Windows.ClientCredential = new NetworkCredential("user", "password", "domain");
proxy.Credentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
proxy.Open();

ICalculator calc = proxy.CreateChannel();

int odd=calc.Add(5,4);

備註

認證方案只能設定一次。

適用於