StorePermissionAttribute.Flags プロパティ
アセンブリ: System (system.dll 内)
構文
Dim instance As StorePermissionAttribute Dim value As StorePermissionFlags value = instance.Flags instance.Flags = value
public: property StorePermissionFlags Flags { StorePermissionFlags get (); void set (StorePermissionFlags value); }
/** @property */ public StorePermissionFlags get_Flags () /** @property */ public void set_Flags (StorePermissionFlags value)
public function get Flags () : StorePermissionFlags public function set Flags (value : StorePermissionFlags)
StorePermissionFlags 値のビットごとの組み合わせ。既定値は NoFlags です。
注意 |
---|
これらのフラグの多くは強力であり、ストアへのアクセスを許可するので、信頼性の高いコードだけに付与するようにしてください。 |
最も強力なフラグは、AddToStore、CreateStore、DeleteStore、および AllFlags です。これらのフラグの使用により発生する具体的な危険性については、各フラグの説明を参照してください。
Flags プロパティを使用して、ストアに追加するためのアクセス許可を拒否するコード例を次に示します。このコード例は、StorePermission クラスのトピックで取り上げているコード例の一部分です。
'Deny the permission the ability to add to a store. <StorePermission(SecurityAction.Deny, Flags:=StorePermissionFlags.AddToStore)> _ Private Shared Sub AddToStore(ByVal cert As X509Certificate2) Try Dim store As New X509Store("teststore", StoreLocation.CurrentUser) store.Open(OpenFlags.ReadWrite) ' The following attempt to add a certificate results in an exception being thrown. store.Add(cert) Return Catch e As SecurityException Console.WriteLine("Security exception thrown when attempting: " + _ CType(e.FirstPermissionThatFailed, System.Security.Permissions.StorePermission).Flags) Return End Try End Sub 'AddToStore
//Deny the permission the ability to add to a store. [StorePermission(SecurityAction.Deny, Flags = StorePermissionFlags.AddToStore)] private static void AddToStore(X509Certificate2 cert) { try { X509Store store = new X509Store("teststore" , StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); // The following attempt to add a certificate results in an exception being thrown. store.Add(cert); return; } catch (SecurityException e) { Console.WriteLine("Security exception thrown when attempting: " + ((StorePermission)e.FirstPermissionThatFailed).Flags); return; } }
//Deny the permission the ability to add to a store. /** @attribute StorePermission(SecurityAction.Deny, Flags = StorePermissionFlags.AddToStore) */ private static void AddToStore(X509Certificate2 cert) { try { X509Store store = new X509Store("teststore" , StoreLocation.CurrentUser); store.Open(OpenFlags.ReadWrite); // The following attempt to add a certificate results in // an exception being thrown. store.Add(cert); return; } catch (System.Security.SecurityException e) { Console.WriteLine("Security exception thrown when attempting: " + ((StorePermission)e.get_FirstPermissionThatFailed()).get_Flags()); return; } } //AddToStore
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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
参照
Weblioに収録されているすべての辞書からStorePermissionAttribute.Flags プロパティを検索する場合は、下記のリンクをクリックしてください。
全ての辞書からStorePermissionAttribute.Flags プロパティを検索
- StorePermissionAttribute.Flags プロパティのページへのリンク