Condividi tramite


AuthenticationLevel Enumerazione

Definizione

Specifica i requisiti client per l'autenticazione e la rappresentazione quando si usano la classe WebRequest e le classi derivate per richiedere una risorsa.

public enum class AuthenticationLevel
public enum AuthenticationLevel
type AuthenticationLevel = 
Public Enum AuthenticationLevel
Ereditarietà
AuthenticationLevel

Campi

Nome Valore Descrizione
None 0

Non è necessaria alcuna autenticazione per il client e il server.

MutualAuthRequested 1

Il client e il server devono essere autenticati. La richiesta non ha esito negativo se il server non è autenticato. Per determinare se si è verificata l'autenticazione reciproca, controllare il valore della IsMutuallyAuthenticated proprietà .

MutualAuthRequired 2

Il client e il server devono essere autenticati. Se il server non è autenticato, l'applicazione riceverà un oggetto con un'eccezione IOExceptionProtocolViolationException interna che indica che l'autenticazione reciproca non è riuscita.

Esempio

Nell'esempio di codice seguente viene illustrata l'impostazione dei flag di autenticazione per una richiesta.


// The following example uses the System, System.Net,
// and System.IO namespaces.

public static void RequestMutualAuth(Uri resource)
{
    // Create a new HttpWebRequest object for the specified resource.
    WebRequest request=(WebRequest) WebRequest.Create(resource);
    // Request mutual authentication.
   request.AuthenticationLevel = AuthenticationLevel.MutualAuthRequested;
    // Supply client credentials.
    request.Credentials = CredentialCache.DefaultCredentials;
    HttpWebResponse response = (HttpWebResponse) request.GetResponse();
    // Determine whether mutual authentication was used.
    Console.WriteLine("Is mutually authenticated? {0}", response.IsMutuallyAuthenticated);
    // Read and display the response.
    Stream streamResponse = response.GetResponseStream();
    StreamReader streamRead = new StreamReader(streamResponse);
    string responseString = streamRead.ReadToEnd();
   Console.WriteLine(responseString);
    // Close the stream objects.
    streamResponse.Close();
    streamRead.Close();
    // Release the HttpWebResponse.
    response.Close();
}

Commenti

I valori di questa enumerazione vengono utilizzati per impostare la AuthenticationLevel proprietà .

Annotazioni

I valori MutualAuthRequired e MutualAuthRequested sono rilevanti per l'autenticazione Kerberos. L'autenticazione Kerberos può essere supportata direttamente oppure può essere usata se viene usato il protocollo di sicurezza Negotiate per selezionare il protocollo di sicurezza effettivo. Per altre informazioni sui protocolli di autenticazione, vedere Autenticazione Internet.

Si applica a