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

例外

示例

下面的示例将此属性设置为在验证客户端请求时使用。

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

注解

身份验证方案只能设置一次。

适用于