HttpTransportBindingElement.AuthenticationScheme Propriété

Définition

Obtient ou définit le schéma d’authentification utilisé pour authentifier les requêtes clientes traitées par un écouteur 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

Valeur de propriété

Une des valeurs d’énumération de l’énumération qui spécifie les protocoles utilisés pour l’authentification AuthenticationSchemes du client. La valeur par défaut est Anonymous.

Exceptions

La valeur de l’objet AuthenticationSchemes a déjà été définie.

Exemples

L’exemple suivant définit cette propriété à utiliser lors de l’authentification des demandes clientes.

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

Remarques

Le schéma d’authentification ne peut être défini qu’une seule fois.

S’applique à