WebRequest.AuthenticationLevel Propriedade
Definição
Importante
Algumas informações se referem a produtos de pré-lançamento que podem ser substancialmente modificados antes do lançamento. A Microsoft não oferece garantias, expressas ou implícitas, das informações aqui fornecidas.
Obtém ou define valores que indicam o nível de autenticação e representação usados para essa solicitação.
public:
property System::Net::Security::AuthenticationLevel AuthenticationLevel { System::Net::Security::AuthenticationLevel get(); void set(System::Net::Security::AuthenticationLevel value); };
public System.Net.Security.AuthenticationLevel AuthenticationLevel { get; set; }
member this.AuthenticationLevel : System.Net.Security.AuthenticationLevel with get, set
Public Property AuthenticationLevel As AuthenticationLevel
Valor da propriedade
Uma combinação bit a bit dos AuthenticationLevel valores. O valor padrão é MutualAuthRequested.
Na autenticação mútua, o cliente e o servidor apresentam credenciais para estabelecer sua identidade. Os MutualAuthRequired valores e os valores MutualAuthRequested são relevantes para a autenticação Kerberos. A autenticação Kerberos pode ter suporte diretamente ou pode ser usada se o protocolo de segurança Negotiate for usado para selecionar o protocolo de segurança real. Para obter mais informações sobre protocolos de autenticação, consulte a Autenticação da Internet.
Para determinar se a autenticação mútua ocorreu, verifique a IsMutuallyAuthenticated propriedade.
Se você especificar o valor do MutualAuthRequired sinalizador de autenticação e a autenticação mútua não ocorrer, seu aplicativo receberá uma ProtocolViolationExceptionIOException exceção interna indicando que a autenticação mútua falhou.
Exemplos
O exemplo de código a seguir define o valor dessa propriedade.
// 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();
}