ProtectionLevel 列挙体とは? わかりやすく解説

ProtectionLevel 列挙体

メモ : この列挙体は、.NET Framework version 2.0新しく追加されたものです。

認証されストリームに対して要求されるセキュリティ サービス示します

名前空間: System.Net.Security
アセンブリ: System (system.dll 内)
構文構文

Dim instance As ProtectionLevel
public enum ProtectionLevel
public enum class ProtectionLevel
public enum ProtectionLevel
public enum ProtectionLevel
メンバメンバ
解説解説

この列挙体は NegotiateStream クラス使用されます。

Windows 95, Windows 98, Windows 98 Second Edition, Windows Millennium Edition プラットフォームメモ : None のみサポートされます。

使用例使用例

クライアント側NegotiateStream作成して使用するコード例次に示します

using System;
using System.Net;
using System.Net.Security;
using System.Net.Sockets;
using System.Security.Principal;

namespace Examples.NegotiateStreamExample
{
    public class SynchronousAuthenticatingTcpClient
 
    {
        public static void
 Main(String[] args)  
        {
            // Establish the remote endpoint for the socket.
            // For this example, use the local machine.
            IPHostEntry ipHostInfo = Dns.GetHostEntry(Dns.GetHostName());
            IPAddress ipAddress = ipHostInfo.AddressList[0];
            // Client and server use port 11000. 
            IPEndPoint remoteEP = new IPEndPoint(ipAddress,11000);
            // Create a TCP/IP socket.
           TcpClient client = new TcpClient();
            // Connect the socket to the remote endpoint.
            client.Connect(remoteEP);
            Console.WriteLine("Client connected to {0}.",
                remoteEP.ToString());
            // Ensure the client does not close when there is 
            // still data to be sent to the server.
            client.LingerState = (new LingerOption(true
,0));
            // Request authentication.
            NetworkStream clientStream = client.GetStream();
            NegotiateStream authStream = new NegotiateStream(clientStream);
 
            // Request authentication for the client only (no mutual
 authentication).
            // Authenicate using the client's default credetials.
            // Permit the server to impersonate the client to access
 resources on the server only.
            // Request that data be transmitted using encryption and
 data signing.
            authStream.AuthenticateAsClient(
                 (NetworkCredential) CredentialCache.DefaultCredentials, 
                 "",
                 ProtectionLevel.EncryptAndSign,
                 TokenImpersonationLevel.Impersonation);
            DisplayAuthenticationProperties(authStream);
            DisplayStreamProperties(authStream);
            if (authStream.CanWrite)
            {
                 // Encode the test data into a byte array.
                byte[] message = System.Text.Encoding.UTF8.GetBytes("Hello from
 the client.");
                authStream.Write(message, 0, message.Length);
          authStream.Flush();
                Console.WriteLine("Sent {0} bytes.", message.Length);
         }
         // Close the client connection.
            authStream.Close();
            Console.WriteLine("Client closed.");
            
    }
         static void DisplayStreamProperties(NegotiateStream
 stream)
        {
             Console.WriteLine("Can read: {0}", stream.CanRead);
             Console.WriteLine("Can write: {0}", stream.CanWrite);
             Console.WriteLine("Can seek: {0}", stream.CanSeek);
             try 
             {
                 // If the underlying stream supports it, display the
 length.
                 Console.WriteLine("Length: {0}", stream.Length);
             } catch (NotSupportedException)
             {
                     Console.WriteLine("Cannot get the length
 of the underlying stream.");
             }
             
             if (stream.CanTimeout)
             {
                 Console.WriteLine("Read time-out: {0}", stream.ReadTimeout);
                 Console.WriteLine("Write time-out: {0}", stream.WriteTimeout);
             }
        }
         static void DisplayAuthenticationProperties(NegotiateStream
 stream)
        {
             Console.WriteLine("IsAuthenticated: {0}", stream.IsAuthenticated);
            Console.WriteLine("IsMutuallyAuthenticated: {0}", stream.IsMutuallyAuthenticated);
            Console.WriteLine("IsEncrypted: {0}", stream.IsEncrypted);
            Console.WriteLine("IsSigned: {0}", stream.IsSigned);
            Console.WriteLine("ImpersonationLevel: {0}", stream.ImpersonationLevel);
            Console.WriteLine("IsServer: {0}", stream.IsServer);
        }
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Net.Security 名前空間


このページでは「.NET Framework クラス ライブラリ リファレンス」からProtectionLevel 列挙体を検索した結果を表示しています。
Weblioに収録されているすべての辞書からProtectionLevel 列挙体を検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からProtectionLevel 列挙体を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「ProtectionLevel 列挙体」の関連用語

ProtectionLevel 列挙体のお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



ProtectionLevel 列挙体のページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS