SecurityAction 列挙体
アセンブリ: mscorlib (mscorlib.dll 内)

<SerializableAttribute> _ <ComVisibleAttribute(True)> _ Public Enumeration SecurityAction

メンバ名 | 説明 | |
---|---|---|
Assert | スタック内の上位にある呼び出し元に現在のアクセス許可オブジェクトによって識別されているリソースへのアクセス許可がない場合でも、呼び出しコードがそのリソースにアクセスできます。詳細については、「Assert メソッドの使用」を参照してください。 | |
Demand | スタック内の上位にあるすべての呼び出し元に、現在のアクセス許可オブジェクトによって指定されているアクセス許可が与えられている必要があります。詳細については、「セキュリティ確認要求」を参照してください。 | |
Deny | 呼び出し元に現在のアクセス許可オブジェクトによって指定されているリソースにアクセスする許可が与えられていても、そのリソースへの呼び出し元からのアクセスは拒否されます。詳細については、「Deny メソッドの使用」を参照してください。 | |
InheritanceDemand | クラスを継承する派生クラスやメソッドをオーバーライドする派生クラスに、指定したアクセス許可が与えられている必要があります。 | |
![]() | LinkDemand | 直前の呼び出し元に、指定したアクセス許可が与えられている必要があります。 宣言セキュリティおよびリンク確認要求の詳細については、「クラスおよびメンバのスコープで使用される宣言セキュリティ」を参照してください。 |
PermitOnly | このアクセス許可オブジェクトによって指定されているリソースだけにアクセスできます。これ以外のリソースへのアクセス許可がコードに与えられている場合でも同様です。詳細については、「PermitOnly メソッドの使用」を参照してください。 | |
RequestMinimum | コードを実行するために必要な最低限のアクセス許可に対する要求。このアクションは、アセンブリのスコープ内でだけ使用できます。 | |
RequestOptional | 省略可能な (実行するために必須ではない) 追加のアクセス許可に対する要求。この要求は、明確に要求されていない他のすべてのアクセス許可を暗黙で拒否します。このアクションは、アセンブリのスコープ内でだけ使用できます。 | |
RequestRefuse | 不正使用される可能性があるアクセス許可を呼び出しコードに与えないようにする要求。このアクションは、アセンブリのスコープ内でだけ使用できます。 |

セキュリティ アクションが実行されるタイミングと、各アクションでサポートされている操作対象を示します。
LinkDemand | ||
InheritanceDemand | 読み込み時 | |
PermitOnly | ||
RequestMinimum | ||
RequestOptional | ||
RequestRefuse |
属性ターゲットの詳細については、Attribute のトピックを参照してください。

このアセンブリのコードに 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.

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SecurityAction 列挙体のページへのリンク