AuthenticationLevel Enumeración

Definición

Especifica los requisitos del cliente para la autenticación y suplantación al utilizar la clase WebRequest y las clases derivadas para solicitar un recurso.Specifies client requirements for authentication and impersonation when using the WebRequest class and derived classes to request a resource.

public enum class AuthenticationLevel
public enum AuthenticationLevel
type AuthenticationLevel = 
Public Enum AuthenticationLevel
Herencia
AuthenticationLevel

Campos

MutualAuthRequested 1

El cliente y el servidor se deben autenticar.The client and server should be authenticated. No se produce ningún error en la solicitud si el servidor no está autenticado.The request does not fail if the server is not authenticated. Para determinar si se realizó una autenticación mutua, compruebe el valor de la propiedad IsMutuallyAuthenticated.To determine whether mutual authentication occurred, check the value of the IsMutuallyAuthenticated property.

MutualAuthRequired 2

El cliente y el servidor se deben autenticar.The client and server should be authenticated. Si el servidor no se autentica, la aplicación recibirá una excepción IOException con una excepción interna ProtocolViolationException que indica que se ha producido un error en la autenticación mutua.If the server is not authenticated, your application will receive an IOException with a ProtocolViolationException inner exception that indicates that mutual authentication failed.

None 0

No se necesita autenticación ni para el cliente ni para el servidor.No authentication is required for the client and server.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer las marcas de autenticación para una solicitud.The following code example demonstrates setting the authentication flags for a request.

// The following example uses the System, System.Net, 
// and System.IO namespaces.
static void RequestMutualAuth( Uri^ resource )
{
   // Create a new HttpWebRequest object for the specified resource.
   WebRequest^ request = dynamic_cast<WebRequest^>(WebRequest::Create( resource ));

   // Request mutual authentication.
   request->AuthenticationLevel = AuthenticationLevel::MutualAuthRequested;

   // Supply client credentials.
   request->Credentials = CredentialCache::DefaultCredentials;
   HttpWebResponse^ response = dynamic_cast<HttpWebResponse^>(request->GetResponse());

   // Determine whether mutual authentication was used.
   Console::WriteLine( L"Is mutually authenticated? {0}", response->IsMutuallyAuthenticated );

   // Read and display the response.
   Stream^ streamResponse = response->GetResponseStream();
   StreamReader^ streamRead = gcnew StreamReader( streamResponse );
   String^ responseString = streamRead->ReadToEnd();
   Console::WriteLine( responseString );

   // Close the stream objects.
   streamResponse->Close();
   streamRead->Close();

   // Release the HttpWebResponse.
   response->Close();
}

// 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();
}

Comentarios

Los valores de esta enumeración se utilizan para establecer la propiedad AuthenticationLevel.The values of this enumeration are used to set the AuthenticationLevel property.

Nota

Los valores MutualAuthRequired y MutualAuthRequested son pertinentes para la autenticación Kerberos.The MutualAuthRequired and MutualAuthRequested values are relevant for Kerberos authentication. La autenticación Kerberos se puede admitir directamente o se puede utilizar si se utiliza el protocolo de seguridad Negotiate para seleccionar el protocolo de seguridad activo.Kerberos authentication can be supported directly, or can be used if the Negotiate security protocol is used to select the actual security protocol. Para obtener más información acerca de los protocolos de autenticación, consulte autenticación de Internet.For more information about authentication protocols, see Internet Authentication.

Se aplica a