共用方式為


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);  

備註

驗證配置只能設定一次。

適用於