AuthenticationLevel 列挙型

定義

WebRequest クラスおよびその派生クラスを使用してリソースを要求する場合の、認証と偽装に関するクライアント要件を指定します。

public enum class AuthenticationLevel
public enum AuthenticationLevel
type AuthenticationLevel = 
Public Enum AuthenticationLevel
継承
AuthenticationLevel

フィールド

MutualAuthRequested 1

クライアントとサーバーを認証する必要があります。 サーバーが認証されていない場合でも、要求は失敗しません。 相互認証が行われたかどうかを判別するには、IsMutuallyAuthenticated プロパティの値を確認します。

MutualAuthRequired 2

クライアントとサーバーを認証する必要があります。 サーバーが認証されていない場合、相互認証が失敗したことを示す ProtocolViolationException 内部例外と共に、IOException がアプリケーションで発生します。

None 0

クライアントとサーバーの認証は必要ありません。

次のコード例は、要求の認証フラグを設定する方法を示しています。

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

注釈

この列挙体の値は、プロパティの設定 AuthenticationLevel に使用されます。

注意

MutualAuthRequired 値と MutualAuthRequested 値は、Kerberos 認証に関連します。 Kerberos 認証は、直接サポートすることも、Negotiate セキュリティ プロトコルを使用して実際のセキュリティ プロトコルを選択する場合に使用することもできます。 認証プロトコルの詳細については、「 インターネット認証」を参照してください。

適用対象