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

SecurityAction 列挙体

宣言セキュリティ使用して実行できるセキュリティ アクション指定します

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

<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Enumeration SecurityAction
Dim instance As SecurityAction
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum SecurityAction
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public enum class SecurityAction
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public enum SecurityAction
SerializableAttribute 
ComVisibleAttribute(true) 
public enum SecurityAction
メンバメンバ
 メンバ説明
Assertスタック内の上位にある呼び出し元に現在のアクセス許可オブジェクトによって識別されているリソースへのアクセス許可ない場合でも、呼び出しコードがそのリソースアクセスできます詳細については、「Assert メソッド使用」を参照してください。 
Demandスタック内の上位にあるすべての呼び出し元に現在のアクセス許可オブジェクトによって指定されているアクセス許可与えられている必要があります詳細については、「セキュリティ確認要求」を参照してください。 
Deny呼び出し元に現在のアクセス許可オブジェクトによって指定されているリソースアクセスする許可与えられていても、そのリソースへの呼び出し元からのアクセス拒否されます。詳細については、「Deny メソッド使用」を参照してください。 
InheritanceDemandクラス継承する派生クラスメソッドオーバーライドする派生クラスに、指定したアクセス許可与えられている必要があります。 
.NET Compact Framework によるサポートLinkDemand直前呼び出し元に指定したアクセス許可与えられている必要があります。 

宣言セキュリティおよびリンク確認要求詳細については、「クラスおよびメンバスコープ使用される宣言セキュリティ」を参照してください

PermitOnlyこのアクセス許可オブジェクトによって指定されているリソースだけにアクセスできます。これ以外のリソースへのアクセス許可コード与えられている場合でも同様です詳細については、「PermitOnly メソッド使用」を参照してください。 
RequestMinimumコード実行するために必要な最低限アクセス許可対す要求。このアクションは、アセンブリスコープ内でだけ使用できます。 
RequestOptional省略可能な (実行するために必須ではない) 追加アクセス許可対す要求。この要求は、明確に要求されていない他のすべてのアクセス許可暗黙拒否します。このアクションは、アセンブリスコープ内でだけ使用できます。  
RequestRefuse不正使用される可能性があるアクセス許可呼び出しコード与えないようにする要求。このアクションは、アセンブリスコープ内でだけ使用できます。 
解説解説
使用例使用例

このアセンブリコードに IsolatedStoragePermission が必要なことを CLR伝え方法次のコード例示します。この例では、分離ストレージ書き込み読み取りを行う方法示します

using System;
using System.Security.Permissions;
using System.IO.IsolatedStorage;
using System.IO;

// Notify the CLR to grant this assembly the IsolatedStorageFilePermission.
 
// This allows the assembly to work with storage files that are isolated
 
// by user and assembly.
[assembly: IsolatedStorageFilePermission(SecurityAction.RequestMinimum, UsageAllowed
 = IsolatedStorageContainment.AssemblyIsolationByUser)]

public sealed class App
{
    static void Main()
    {
        // Attempt to create a storage file that is isolated by user
 and assembly.
        // IsolatedStorageFilePermission granted to the attribute at
 the top of this file 
        // allows CLR to load this assembly and execution of this statement.
        using (Stream s = new IsolatedStorageFileStream("AssemblyData",
 FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly()))
        {
         
             // Write some data out to the isolated file.
             using (StreamWriter sw = new StreamWriter(s))
             {
                sw.Write("This is some test data.");
             }
        }

        // Attempt to open the file that was previously created.
        using (Stream s = new IsolatedStorageFileStream("AssemblyData",
 FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly()))
        {
             // Read the data from the file and display it.
             using (StreamReader sr = new StreamReader(s))
             {
                 Console.WriteLine(sr.ReadLine());
             }
        }
    }
}

// This code produces the following output.
//
//  Some test data.
using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::IO::IsolatedStorage;
using namespace System::IO;

// Notify the CLR to grant this assembly the IsolatedStorage-
// FilePermission. This allows the assembly to work with storage
// files that are isolated by user and assembly.
[assembly: IsolatedStorageFilePermission(
    SecurityAction::RequestMinimum, UsageAllowed =
    IsolatedStorageContainment::AssemblyIsolationByUser)];
int main()
{
    try
    {
        // Attempt to create a storage file that is isolated by
        // user and assembly. IsolatedStorageFilePermission
        // granted to the attribute at the top of this file
        // allows CLR to load this assembly and execution of this
        // statement.
        Stream^ fileCreateStream = gcnew
            IsolatedStorageFileStream(
            "AssemblyData",
            FileMode::Create,
            IsolatedStorageFile::GetUserStoreForAssembly());

        StreamWriter^ streamWriter = gcnew StreamWriter(
            fileCreateStream);
        try
        {
            // Write some data out to the isolated file.

            streamWriter->Write("This is some test data.");
            streamWriter->Close();    
        }
        finally
        {
            delete fileCreateStream;
            delete streamWriter;
        } 
    }
    catch (IOException^ ex)
    {
        Console::WriteLine(ex->Message);
    }

    try
    {
        Stream^ fileOpenStream =
            gcnew IsolatedStorageFileStream(
            "AssemblyData",
            FileMode::Open,
            IsolatedStorageFile::GetUserStoreForAssembly());
        // Attempt to open the file that was previously created.

        StreamReader^ streamReader = gcnew StreamReader(
            fileOpenStream);
        try
        { 
            // Read the data from the file and display it.

            Console::WriteLine(streamReader->ReadLine());
            streamReader->Close();
        }
        finally
        {
            delete fileOpenStream;
            delete streamReader;
        }
    }
    catch (FileNotFoundException^ ex)
    {
        Console::WriteLine(ex->Message);
    }
    catch (IOException^ ex)
    {
        Console::WriteLine(ex->Message);
    }
}

// This code produces the following output.
//
//  This is some test data.
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
System.Security.Permissions 名前空間



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

辞書ショートカット

すべての辞書の索引

「SecurityAction 列挙体」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS