SecurityManager.SecurityEnabled プロパティ
アセンブリ: mscorlib (mscorlib.dll 内)

<ObsoleteAttribute("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")> _ Public Shared Property SecurityEnabled As Boolean
Dim value As Boolean value = SecurityManager.SecurityEnabled SecurityManager.SecurityEnabled = value
[ObsoleteAttribute("Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")] public static bool SecurityEnabled { get; set; }
[ObsoleteAttribute(L"Because security can no longer be turned off permanently, setting the SecurityEnabled property no longer has any effect. Reading the property will still indicate whether security has been turned off temporarily.")] public: static property bool SecurityEnabled { bool get (); void set (bool value); }
/** @property */ public static boolean get_SecurityEnabled () /** @property */ public static void set_SecurityEnabled (boolean value)
public static function get SecurityEnabled () : boolean public static function set SecurityEnabled (value : boolean)
セキュリティが有効な場合は true。それ以外の場合は false。


このプロパティを コード アクセス セキュリティ ポリシー ツール (Caspol.exe)-security (-s) オプションで使用して、コード ベース セキュリティをオフにすることができます。
SecurityEnabled を使用すると、管理者はコード アクセス セキュリティを無効にすることができます。コード アクセス セキュリティが無効な場合、すべてのコード アクセス要求は成功します。実質的にこのプロパティは、すべてのコードに FullTrust を与えます。コード アクセス セキュリティを無効にすると、セキュリティ システムがバイパスされます。そのため、すべてのコードに FullTrust を与える同等のセキュリティ ポリシーよりも、コードのパフォーマンスが多少向上することがあります。このプロパティを使用しても、ロール ベースのセキュリティが無効になることはありません。したがって、PrincipalPermission 要求は影響を受けません。
![]() |
---|
コード アクセス セキュリティを無効にすると、システムはウイルスやワームなどの悪意あるコードによる攻撃を受けやすくなります。コード アクセス セキュリティを無効にしても、マネージ コードの実行が自動的にブロックされることは一切ありません。コード アクセス セキュリティ システムによる制限がない状態でマネージ コードが実行できるようになるだけです。これを使用するときは、細心の注意を払ってください。セキュリティをオフにすると確かにパフォーマンスは向上しますが、このセキュリティをオフにするのは、別のセキュリティ対策によってシステムのセキュリティが確保されている場合だけにしてください。その他のセキュリティ対策の例として、パブリック ネットワークからの切断や、物理的なコンピュータの保護などがあります。 |
このプロパティの変更は、SavePolicy を呼び出すまでレジストリで永続化されません。新しいプロセスは、レジストリで永続化されるまで、変更の影響を受けません。実行中のプロセスでこのプロパティの値を変更しても、必ずしも予想どおりに状態は変更されません。変更を確実に有効にするには、SavePolicy を呼び出して新しいプロセスを開始する必要があります。

セキュリティが有効になっていることを確認する例を次に示します。
If Not SecurityManager.SecurityEnabled Then Throw New SecurityException(myResourceManager.GetString("Security_Required")) End If
if ( !SecurityManager.SecurityEnabled ) { throw new SecurityException(myResourceManager.GetString("Security_Required")); }
if ( !SecurityManager::SecurityEnabled ) { throw gcnew SecurityException( myResourceManager->GetString( "Security_Required" ) ); }


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- SecurityManager.SecurityEnabled プロパティのページへのリンク