IsolatedStorageContainment 列挙型

定義

注意事項

Code Access Security is not supported or honored by the runtime.

使用できる分離ストレージを指定します。

public enum class IsolatedStorageContainment
public enum IsolatedStorageContainment
[System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public enum IsolatedStorageContainment
[System.Serializable]
public enum IsolatedStorageContainment
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum IsolatedStorageContainment
type IsolatedStorageContainment = 
[<System.Obsolete("Code Access Security is not supported or honored by the runtime.", DiagnosticId="SYSLIB0003", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
type IsolatedStorageContainment = 
[<System.Serializable>]
type IsolatedStorageContainment = 
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type IsolatedStorageContainment = 
Public Enum IsolatedStorageContainment
継承
IsolatedStorageContainment
属性

フィールド

AdministerIsolatedStorageByUser 112

ユーザー ストアの無制限の管理機能。 ユーザー ストア全体の参照と削除を許可しますが、ユーザー独自のドメイン/アセンブリ ID 以外の読み取りアクセスは許可しません。

ApplicationIsolationByMachine 69

ストレージは、初めにコンピューターごとに分離され、次にアプリケーションごとに分離されます。 これは、任意のドメイン コンテキストでアクセスできるアプリケーションのデータ ストアを提供します。 アプリケーションごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

ApplicationIsolationByRoamingUser 101

ストレージは、初めにユーザーごとに分離され、次にアプリケーションの証拠ごとに分離されます。 Windows ユーザー データ ローミングが有効になっている場合、ストレージは移動します。 これは、任意のドメイン コンテキストでアクセスできるアプリケーションのデータ ストアを提供します。 アプリケーションごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

ApplicationIsolationByUser 21

ストレージは、初めにユーザーごとに分離され、次にアプリケーションごとに分離されます。 また、ストレージは、コンピューターごとにも分離されます。 これは、任意のドメイン コンテキストでアクセスできるアプリケーションのデータ ストアを提供します。 アプリケーションごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

AssemblyIsolationByMachine 64

ストレージは、初めにコンピューターごとに分離され、次にコード アセンブリごとに分離されます。 これは、任意のドメイン コンテキストでアクセスできるアセンブリにデータ ストアを提供します。 アセンブリごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

AssemblyIsolationByRoamingUser 96

ストレージは、初めにユーザーごとに分離され、次にアセンブリの証拠ごとに分離されます。 Windows ユーザー データ ローミングが有効になっている場合、ストレージは移動します。 これは、任意のドメイン コンテキストでアクセスできるアセンブリにデータ ストアを提供します。 アセンブリごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

AssemblyIsolationByUser 32

ストレージは、初めにユーザーごとに分離され、次にコード アセンブリごとに分離されます。 また、ストレージは、コンピューターごとにも分離されます。 これは、任意のドメイン コンテキストでアクセスできるアセンブリにデータ ストアを提供します。 アセンブリごとのデータ コンパートメントでは、さらに信頼性が必要となります。これは、アプリケーション間に "トンネル" が発生し、特定の Web サイトでアプリケーションのデータ分離を損なう可能性があるためです。

DomainIsolationByMachine 48

ストレージは、初めにコンピューターごとに分離され、次にドメインとアセンブリごとに分離されます。 同じアプリケーションのコンテキストで、同じコンピューター上で実行する場合にだけデータにアクセスできます。 これはサード パーティ アセンブリが、プライベート データ ストアを保持する場合に役立ちます。

DomainIsolationByRoamingUser 80

ストレージは、初めにユーザーごとに分離され、次にドメインとアセンブリごとに分離されます。 Windows ユーザー データ ローミングが有効になっている場合、ストレージは移動します。 同じアプリケーションのコンテキストで、同じユーザーが実行する場合にだけデータにアクセスできます。 これはサード パーティ アセンブリが、プライベート データ ストアを保持する場合に役立ちます。

DomainIsolationByUser 16

ストレージは、初めにユーザーごとに分離され、次にドメインとアセンブリごとに分離されます。 また、ストレージは、コンピューターごとにも分離されます。 同じアプリケーションのコンテキストで、同じユーザーが実行する場合にだけデータにアクセスできます。 これはサード パーティ アセンブリが、プライベート データ ストアを保持する場合に役立ちます。

None 0

分離ストレージの使用は許可されません。

UnrestrictedIsolatedStorage 240

分離ストレージの使用は、制限なしに許可されます。 コードは、ドメインまたはアセンブリの ID にかかわらずユーザー ストアの任意の部分へのフル アクセスを持ちます。 この分離ストレージの使用には、分離ストレージ データ ストアの内容を列挙する機能が含まれています。

この例では、このアセンブリ内のコードに必要 IsolatedStoragePermission であることを CLR に伝える方法を示し、分離ストレージから書き込んで読み取る方法も示します。

using namespace System;
using namespace System::Security;
using namespace System::Security::Permissions;
using namespace System::IO::IsolatedStorage;
using namespace System::IO;


static void WriteIsolatedStorage()
{
    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);
    }
}
// Notify the CLR to only grant IsolatedStorageFilePermission to called methods. 
// This restricts the called methods to working only with storage files that are isolated 
// by user and assembly.
[IsolatedStorageFilePermission(SecurityAction::PermitOnly, UsageAllowed = IsolatedStorageContainment::AssemblyIsolationByUser)]
int main()
{
    WriteIsolatedStorage();
}

// This code produces the following output.
//
//  This is some test data.
using System;
using System.Security.Permissions;
using System.IO.IsolatedStorage;
using System.IO;

// Notify the CLR to only grant IsolatedStorageFilePermission to called methods.
// This restricts the called methods to working only with storage files that are isolated
// by user and assembly.
[IsolatedStorageFilePermission(SecurityAction.PermitOnly, UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser)]
public sealed class App
{
    static void Main()
    {
        WriteIsolatedStorage();
    }
    private static void WriteIsolatedStorage()
    {
        // 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.
Option Strict On
Imports System.Security.Permissions
Imports System.IO.IsolatedStorage
Imports System.IO


' Notify the CLR to only grant IsolatedStorageFilePermission to called methods. 
' This restricts the called methods to working only with storage files that are isolated 
' by user and assembly.
<IsolatedStorageFilePermission(SecurityAction.PermitOnly, UsageAllowed:=IsolatedStorageContainment.AssemblyIsolationByUser)> _
Public NotInheritable Class App

    Shared Sub Main()
        WriteIsolatedStorage()
    End Sub
    Shared Sub WriteIsolatedStorage()
        ' 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.
        Dim s As New IsolatedStorageFileStream("AssemblyData", FileMode.Create, IsolatedStorageFile.GetUserStoreForAssembly())
        Try

            ' Write some data out to the isolated file.
            Dim sw As New StreamWriter(s)
            Try
                sw.Write("This is some test data.")
            Finally
                sw.Dispose()
            End Try
        Finally
            s.Dispose()
        End Try

        ' Attempt to open the file that was previously created.
        Dim t As New IsolatedStorageFileStream("AssemblyData", FileMode.Open, IsolatedStorageFile.GetUserStoreForAssembly())
        Try
            ' Read the data from the file and display it.
            Dim sr As New StreamReader(t)
            Try
                Console.WriteLine(sr.ReadLine())
            Finally
                sr.Dispose()
            End Try
        Finally
            t.Dispose()
        End Try

    End Sub
End Class

' This code produces the following output.
'
'  Some test data.

注釈

分離ストレージは、証拠を使用して、アプリケーションまたはコンポーネントが使用する一意の記憶域を決定します。 アセンブリの ID によって、そのアセンブリで使用する仮想ファイル システムのルートが一意に決定されます。 したがって、ファイル システムやレジストリなどの共通リソースを共有する多くのアプリケーションやコンポーネントではなく、それぞれに固有のファイル領域が割り当てられます。

分離ストレージを割り当てる場合は、次の 4 つの基本的な分離スコープが使用されます。

  • User - コードは常に現在のユーザーに従ってスコープ指定されます。 同じアセンブリは、異なるユーザーによって実行されるときに、異なるストアを受け取ります。

  • Machine - コードは常にマシンに従ってスコープ指定されます。 同じアセンブリは、同じコンピューター上の異なるユーザーによって実行されるときに、同じストアを受け取ります。

  • Assembly- コードは、厳密な名前 (Microsoft.Office など) または Microsoft.Office* によって暗号化によって識別されます。Word)、発行元別 (公開キーに基づく)、URL 別 (たとえば、http://www.fourthcoffee.com/process/grind.htmサイト別、ゾーン別)。

  • Domain - コードは、アプリケーション ドメインに関連付けられている証拠に基づいて識別されます。 Web アプリケーション ID は、サイトの URL、または Web ページの URL、サイト、またはゾーンから派生します。 ローカル コード ID は、アプリケーション ディレクトリパスに基づいています。

URL、サイト、ゾーンの定義については、〘、および ZoneIdentityPermissionを参照してください。UrlIdentityPermissionSiteIdentityPermission

これらの ID はグループ化され、その場合、目的の分離ストレージが作成されるまで ID が次々に適用されます。 有効なグループ化は、User+Assembly と User+Assembly+Domain です。 この ID のグループ化は、さまざまなアプリケーションで役立ちます。

データがドメイン、ユーザー、およびアセンブリによって格納されている場合、データは、そのアセンブリ内のコードのみがデータにアクセスできるプライベートです。 また、データ ストアは、実行されるアプリケーションによって分離されるため、アセンブリは他のアプリケーションにデータを公開することによって潜在的なリークを表しません。

アセンブリとユーザーによる分離は、複数のアプリケーションに適用されるユーザー データに使用できます。たとえば、ライセンス情報や、アプリケーションに依存しないユーザーの個人情報 (名前、認証資格情報など) などです。

IsolatedStorageContainment は、アプリケーションで分離ストレージの使用が許可されているかどうかを判断するフラグと、使用できる ID の組み合わせを公開します。 また、アプリケーションがユーザーと共にローミングできる場所に情報を格納できるかどうかを決定します (Windows移動ユーザー プロファイルまたはフォルダー リダイレクトを構成する必要があります)。

適用対象

こちらもご覧ください