From 8248cc24c4abb6c4e0ff0b43a838adbab6e3e4ae Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Wed, 18 Jun 2025 17:03:28 +0200
Subject: [PATCH 1/3] delete code example text from obsolete types
---
.../CipherAlgorithmType.xml | 22 +-
.../ExchangeAlgorithmType.xml | 22 +-
.../HashAlgorithmType.xml | 2 -
.../CodeAccessSecurityAttribute.xml | 31 +-
.../DataProtectionPermission.xml | 215 ++-----
.../EnvironmentPermission.xml | 156 ++---
.../FileDialogPermissionAttribute.xml | 31 +-
.../FileIOPermission.xml | 470 ++++++--------
.../FileIOPermissionAttribute.xml | 233 +++----
.../GacIdentityPermission.xml | 136 ++--
.../GacIdentityPermissionAttribute.xml | 74 +--
.../HostProtectionAttribute.xml | 104 +--
.../HostProtectionResource.xml | 13 +-
.../IUnrestrictedPermission.xml | 30 +-
.../IsolatedStorageContainment.xml | 57 +-
.../KeyContainerPermission.xml | 142 ++---
.../KeyContainerPermissionAccessEntry.xml | 227 +++----
.../KeyContainerPermissionFlags.xml | 18 +-
.../MediaPermission.xml | 170 ++---
.../MediaPermissionAttribute.xml | 102 +--
.../MediaPermissionAudio.xml | 12 +-
.../MediaPermissionImage.xml | 12 +-
.../MediaPermissionVideo.xml | 12 +-
.../PermissionSetAttribute.xml | 94 ++-
.../PrincipalPermission.xml | 214 +++----
.../PrincipalPermissionAttribute.xml | 84 +--
.../PublisherIdentityPermission.xml | 127 ++--
.../ReflectionPermission.xml | 194 ++----
.../ReflectionPermissionFlag.xml | 8 -
.../RegistryPermission.xml | 266 ++++----
.../ResourcePermissionBase.xml | 136 ++--
.../ResourcePermissionBaseEntry.xml | 29 +-
.../SecurityAction.xml | 51 +-
.../SecurityAttribute.xml | 49 +-
.../SecurityPermission.xml | 99 ++-
.../SecurityPermissionFlag.xml | 18 +-
.../StorePermissionFlags.xml | 15 +-
.../StrongNameIdentityPermission.xml | 90 ---
.../UIPermission.xml | 245 ++-----
.../UrlIdentityPermission.xml | 188 +++---
.../WebBrowserPermission.xml | 40 +-
.../WebBrowserPermissionAttribute.xml | 28 +-
.../WebBrowserPermissionLevel.xml | 10 -
.../ZoneIdentityPermission.xml | 20 +-
xml/System.Security.Policy/FileCodeGroup.xml | 204 ++----
.../FirstMatchCodeGroup.xml | 142 ++---
xml/System.Security.Policy/GacInstalled.xml | 125 +---
xml/System.Security/CodeAccessPermission.xml | 78 +--
xml/System.Security/IPermission.xml | 70 +-
xml/System.Security/PermissionSet.xml | 596 ++++++------------
xml/System.Security/SecurityContext.xml | 158 +++--
xml/System.Security/SecurityManager.xml | 24 +-
52 files changed, 1901 insertions(+), 3792 deletions(-)
diff --git a/xml/System.Security.Authentication/CipherAlgorithmType.xml b/xml/System.Security.Authentication/CipherAlgorithmType.xml
index 1eeeaab592b..a38fa0e1d12 100644
--- a/xml/System.Security.Authentication/CipherAlgorithmType.xml
+++ b/xml/System.Security.Authentication/CipherAlgorithmType.xml
@@ -49,19 +49,17 @@
Defines the possible cipher algorithms for the class.
- property.
-
-
-
-## Examples
- The following example displays the properties of an .
-
+ property.
+
+## Examples
+ The following example displays the properties of an .
+
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet3":::
-
+ :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet3":::
+
]]>
diff --git a/xml/System.Security.Authentication/ExchangeAlgorithmType.xml b/xml/System.Security.Authentication/ExchangeAlgorithmType.xml
index 4588640cced..9c291c57694 100644
--- a/xml/System.Security.Authentication/ExchangeAlgorithmType.xml
+++ b/xml/System.Security.Authentication/ExchangeAlgorithmType.xml
@@ -49,19 +49,17 @@
Specifies the algorithm used to create keys shared by the client and server.
- property.
-
-
-
-## Examples
- The following example displays the properties of an .
-
+ property.
+
+## Examples
+ The following example displays the properties of an .
+
:::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/NclSslClientAsync/CPP/NclSslClientAsync.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet3":::
-
+ :::code language="csharp" source="~/snippets/csharp/System.Net.Security/LocalCertificateSelectionCallback/Overview/clientasync.cs" id="Snippet3":::
+
]]>
diff --git a/xml/System.Security.Authentication/HashAlgorithmType.xml b/xml/System.Security.Authentication/HashAlgorithmType.xml
index d9d819b2c0b..027ded03d7b 100644
--- a/xml/System.Security.Authentication/HashAlgorithmType.xml
+++ b/xml/System.Security.Authentication/HashAlgorithmType.xml
@@ -54,8 +54,6 @@
## Remarks
This enumeration specifies valid values for the property.
-
-
## Examples
The following example displays the properties of an after authentication has succeeded.
diff --git a/xml/System.Security.Permissions/CodeAccessSecurityAttribute.xml b/xml/System.Security.Permissions/CodeAccessSecurityAttribute.xml
index b84872b6d12..33fe6054aeb 100644
--- a/xml/System.Security.Permissions/CodeAccessSecurityAttribute.xml
+++ b/xml/System.Security.Permissions/CodeAccessSecurityAttribute.xml
@@ -91,25 +91,18 @@
Specifies the base attribute class for code access security.
- , for example, `Demand`, with a custom security attribute.
-
- The types that derive from are used to help restrict access to resources or securable operations.
-
+ This attribute class associates a , for example, `Demand`, with a custom security attribute.
+
+ The types that derive from are used to help restrict access to resources or securable operations.
+
The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. Use the corresponding permission class derived from for imperative security.
-
-## Examples
- The following example shows a permission attribute derived from the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/CPP/nameidpermissionattribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermissionattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/VB/nameidpermissionattribute.vb" id="Snippet1":::
-
+
]]>
@@ -172,11 +165,11 @@
One of the values.
Initializes a new instance of with the specified .
-
diff --git a/xml/System.Security.Permissions/DataProtectionPermission.xml b/xml/System.Security.Permissions/DataProtectionPermission.xml
index 5040b715915..ddfa069d683 100644
--- a/xml/System.Security.Permissions/DataProtectionPermission.xml
+++ b/xml/System.Security.Permissions/DataProtectionPermission.xml
@@ -46,14 +46,14 @@
Controls the ability to access encrypted data and memory. This class cannot be inherited.
- and classes.
-
+ This permission is used to control the ability to encrypt data and memory using the and classes.
+
]]>
@@ -98,18 +98,7 @@
A bitwise combination of the values.
Initializes a new instance of the class with the specified permission flags.
-
- constructor. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet2":::
-
- ]]>
-
+ To be added. is not a valid combination of the values.
@@ -147,20 +136,11 @@
One of the values.
Initializes a new instance of the class with the specified permission state.
- constructor. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet9":::
-
+
@@ -200,23 +180,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
- method. This code example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet5":::
-
+
@@ -252,20 +220,11 @@
Gets or sets the data and memory protection flags.A bitwise combination of the values.
- and classes can be used.
-
-
-
-## Examples
- The following code example shows the use of the property. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet10":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet10":::
-
+ and classes can be used.
+
]]>The specified value is not a valid combination of the values.
@@ -305,32 +264,20 @@
A that contains the XML encoding used to reconstruct the permission.
Reconstructs a permission with a specific state from an XML encoding.
- method reconstructs a object from an XML encoding defined by the class. Use the method to XML-encode the , including state information.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet7":::
-
+ method reconstructs a object from an XML encoding defined by the class. Use the method to XML-encode the , including state information.
+
]]> is .
- is not a valid permission element.
-
- -or-
-
+ is not a valid permission element.
+
+ -or-
+
The version number of is not supported.
@@ -369,20 +316,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet10":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet10":::
-
+
@@ -425,23 +363,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- access is a subset of a permission for access.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet3":::
-
+ access is a subset of a permission for access.
+
]]>
@@ -484,20 +410,11 @@
if the current permission is unrestricted; otherwise, .
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet4":::
-
+
@@ -534,23 +451,11 @@
Creates an XML encoding of the permission and its current state.An XML encoding of the permission, including state information.
- method to restore the state information from a .
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet7":::
-
+ method to restore the state information from a .
+
]]>
@@ -590,23 +495,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/DataProtectionPermission/.ctor/dataprotect.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb" id="Snippet6":::
-
+ is a permission that represents all operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>
diff --git a/xml/System.Security.Permissions/EnvironmentPermission.xml b/xml/System.Security.Permissions/EnvironmentPermission.xml
index 560384ba547..b7fedd98f92 100644
--- a/xml/System.Security.Permissions/EnvironmentPermission.xml
+++ b/xml/System.Security.Permissions/EnvironmentPermission.xml
@@ -53,17 +53,17 @@
Controls access to system and user environment variables. This class cannot be inherited.
- [!NOTE]
-> In versions of .NET Framework before .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
-
+> In versions of .NET Framework before .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
+
]]>
@@ -113,11 +113,11 @@
One of the values.
Initializes a new instance of the class with either restricted or unrestricted permission as specified.
- The parameter is not a valid value of .
@@ -164,11 +164,11 @@
A list of environment variables (semicolon-separated) to which access is granted.
Initializes a new instance of the class with the specified access to the specified environment variables.
- values to be specified. This access applies to all listed environment variables. Use to define complex permissions.
-
+ values to be specified. This access applies to all listed environment variables. Use to define complex permissions.
+
]]>The parameter is .
@@ -219,19 +219,11 @@
A list of environment variables (semicolon-separated).
Adds access for the specified environment variables to the existing state of the permission.
- method.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/EnvironmentPermission/AddPathList/environmentpermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb" id="Snippet7":::
-
+ The parameter is .
@@ -272,11 +264,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -324,10 +316,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -368,29 +360,21 @@
Gets all environment variables with the specified .A list of environment variables (semicolon-separated) for the selected flag.
- [!NOTE]
-> The `flag` parameter is limited to the values of , which represent single types of environment variable access. Those values are and . The values acceptable to `flag` do not include and , which do not represent single types of environment variable access.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/EnvironmentPermission/AddPathList/environmentpermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb" id="Snippet7":::
-
+> The `flag` parameter is limited to the values of , which represent single types of environment variable access. Those values are and . The values acceptable to `flag` do not include and , which do not represent single types of environment variable access.
+
]]>
- is not a valid value of .
-
- -or-
-
+ is not a valid value of .
+
+ -or-
+
is , which represents more than one type of environment variable access, or , which does not represent any type of environment variable access.
@@ -437,11 +421,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- The parameter is not and is not of the same type as the current permission.
@@ -491,11 +475,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- The parameter is not and is not of the same type as the current permission.
@@ -539,11 +523,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -592,19 +576,11 @@
A list of environment variables (semicolon-separated).
Sets the specified access to the specified environment variables to the existing state of the permission.
- method. This code example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/EnvironmentPermission/AddPathList/environmentpermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb" id="Snippet7":::
-
+ The parameter is .
@@ -690,11 +666,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
+ is a permission that represents all the states represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/FileDialogPermissionAttribute.xml b/xml/System.Security.Permissions/FileDialogPermissionAttribute.xml
index 24c3605b3be..8f1678f0d84 100644
--- a/xml/System.Security.Permissions/FileDialogPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/FileDialogPermissionAttribute.xml
@@ -53,23 +53,16 @@
Allows security actions for to be applied to code using declarative security. This class cannot be inherited.
- that is used.
-
+ The scope of the declaration that is allowed depends on the that is used.
+
The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
-
-## Examples
- The following code example demonstrates how to demand that the calling code have . Demands are typically made in managed libraries (DLLs) to help protect methods or classes from potentially harmful code.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/CPP/source.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileDialogPermissionAttribute/Overview/source.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/VB/source.vb" id="Snippet2":::
-
+
]]>
@@ -146,13 +139,13 @@
Creates and returns a new .A that corresponds to this attribute.
-
diff --git a/xml/System.Security.Permissions/FileIOPermission.xml b/xml/System.Security.Permissions/FileIOPermission.xml
index 55763d523bb..4243cee41b7 100644
--- a/xml/System.Security.Permissions/FileIOPermission.xml
+++ b/xml/System.Security.Permissions/FileIOPermission.xml
@@ -53,51 +53,36 @@
Controls the ability to access files and folders. This class cannot be inherited.
- :
-
-- `Read`: Read access to the contents of the file or access to information about the file, such as its length or last modification time.
-
-- `Write`: Write access to the contents of the file or access to change information about the file, such as its name. Also allows for deletion and overwriting.
-
-- `Append`: Ability to write to the end of a file only. No ability to read.
-
-- `PathDiscovery`: Access to the information in the path itself. This helps protect sensitive information in the path, such as user names, as well as information about the directory structure that is revealed in the path. This value does not grant access to files or folders represented by the path.
-
+ This permission distinguishes between the following four types of file IO access provided by :
+
+- `Read`: Read access to the contents of the file or access to information about the file, such as its length or last modification time.
+
+- `Write`: Write access to the contents of the file or access to change information about the file, such as its name. Also allows for deletion and overwriting.
+
+- `Append`: Ability to write to the end of a file only. No ability to read.
+
+- `PathDiscovery`: Access to the information in the path itself. This helps protect sensitive information in the path, such as user names, as well as information about the directory structure that is revealed in the path. This value does not grant access to files or folders represented by the path.
+
> [!NOTE]
-> Giving access to an assembly is similar to granting it full trust. If an application should not write to the file system, it should not have access.
-
- All these permissions are independent, meaning that rights to one do not imply rights to another. For example, `Write` permission does not imply permission to `Read` or `Append`. If more than one permission is desired, they can be combined using a bitwise OR as shown in the code example that follows. File permission is defined in terms of canonical absolute paths; calls should always be made with canonical file paths.
-
- describes protected operations on files and folders. The class helps provide secure access to files and folders. The security access check is performed when the handle to the file is created. By doing the check at creation time, the performance impact of the security check is minimized. Opening a file happens once, while reading and writing can happen multiple times. Once the file is opened, no further checks are done. If the object is passed to an untrusted caller, it can be misused. For example, file handles should not be stored in public global statics where code with less permission can access them.
-
- specifies actions that can be performed on the file or folder. In addition, these actions can be combined using a bitwise OR to form complex instances.
-
- Access to a folder implies access to all the files it contains, as well as access to all the files and folders in its subfolders. For example, `Read` access to C:\folder1\ implies `Read` access to C:\folder1\file1.txt, C:\folder1\folder2\\, C:\folder1\folder2\file2.txt, and so on.
-
+> Giving access to an assembly is similar to granting it full trust. If an application should not write to the file system, it should not have access.
+
+ All these permissions are independent, meaning that rights to one do not imply rights to another. For example, `Write` permission does not imply permission to `Read` or `Append`. If more than one permission is desired, they can be combined using a bitwise OR as shown in the code example that follows. File permission is defined in terms of canonical absolute paths; calls should always be made with canonical file paths.
+
+ describes protected operations on files and folders. The class helps provide secure access to files and folders. The security access check is performed when the handle to the file is created. By doing the check at creation time, the performance impact of the security check is minimized. Opening a file happens once, while reading and writing can happen multiple times. Once the file is opened, no further checks are done. If the object is passed to an untrusted caller, it can be misused. For example, file handles should not be stored in public global statics where code with less permission can access them.
+
+ specifies actions that can be performed on the file or folder. In addition, these actions can be combined using a bitwise OR to form complex instances.
+
+ Access to a folder implies access to all the files it contains, as well as access to all the files and folders in its subfolders. For example, `Read` access to C:\folder1\ implies `Read` access to C:\folder1\file1.txt, C:\folder1\folder2\\, C:\folder1\folder2\file2.txt, and so on.
+
> [!NOTE]
-> In versions of the .NET Framework before the .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
-
-
-
-## Examples
- The following examples illustrate code that uses . After the following two lines of code, the object `f` represents permission to read all files on the client computer's local disks. The code example then demands the permission to determine whether the application has permission to read the files.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet1":::
-
- After the following two lines of code, the object `f2` represents permissions to read C:\test_r and read and write to C:\example\out.txt. `Read` and `Write` represent the file/folder permissions as previously described. After creating the permission, the code demands the permission to determine whether the application has the right to read and write to the file.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet2":::
-
+> In versions of the .NET Framework before the .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
+
]]>
@@ -147,20 +132,11 @@
One of the enumeration values.
Initializes a new instance of the class with fully restricted or unrestricted permission as specified.
- class with fully restricted read access.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet1":::
-
+ The parameter is not a valid value of .
@@ -207,30 +183,21 @@
The absolute path of the file or directory.
Initializes a new instance of the class with the specified access to the designated file or directory.
- values to be specified for the specified file or directory. Use the method to define complex permissions.
-
-
-
-## Examples
- The following code example shows the use of the constructor to create a new instance of the class, which provides complete access to the C:\test_r file.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet2":::
-
+ values to be specified for the specified file or directory. Use the method to define complex permissions.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
- The parameter is not a valid string.
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
+ The parameter is not a valid string.
+
+ -or-
+
The parameter does not specify the absolute path to the file or directory.
@@ -275,17 +242,17 @@
An array containing the absolute paths of the files and directories.
Initializes a new instance of the class with the specified access to the designated files and directories.
- value to be specified for the specified files and directories. Use the method to define complex permissions.
-
+ value to be specified for the specified files and directories. Use the method to define complex permissions.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
An entry in the array is not a valid string.
@@ -338,26 +305,26 @@
The absolute path of the file or directory.
Initializes a new instance of the class with the specified access to the designated file or directory and the specified access rights to file control information.
- value to be specified for the specified file or directories. Use the method to define complex permissions.
-
- The `control` parameter specifies whether the access control list (ACL) for the file or directory specified by `path` can be changed, viewed, or cannot be accessed.
-
+ value to be specified for the specified file or directories. Use the method to define complex permissions.
+
+ The `control` parameter specifies whether the access control list (ACL) for the file or directory specified by `path` can be changed, viewed, or cannot be accessed.
+
> [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
- The parameter is not a valid string.
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
+ The parameter is not a valid string.
+
+ -or-
+
The parameter does not specify the absolute path to the file or directory.
@@ -410,22 +377,22 @@
An array containing the absolute paths of the files and directories.
Initializes a new instance of the class with the specified access to the designated files and directories and the specified access rights to file control information.
- value to be specified for the specified files and directories. Use the method to define complex permissions.
-
- The `control` parameter specifies whether the access control list (ACL) for the file or directory specified by `path` can be changed, viewed, or cannot be accessed.
-
+ value to be specified for the specified files and directories. Use the method to define complex permissions.
+
+ The `control` parameter specifies whether the access control list (ACL) for the file or directory specified by `path` can be changed, viewed, or cannot be accessed.
+
> [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change or view an ACL is an important permission and should be granted with caution.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
An entry in the array is not a valid string.
@@ -483,30 +450,21 @@
The absolute path of a file or directory.
Adds access for the specified file or directory to the existing state of the permission.
- method.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet2":::
-
+
- The parameter is not a valid value of .
-
- -or-
-
- The parameter is not a valid string.
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
+ The parameter is not a valid string.
+
+ -or-
+
The parameter did not specify the absolute path to the file or directory.The parameter is .The parameter has an invalid format.
@@ -556,17 +514,17 @@
An array containing the absolute paths of the files and directories.
Adds access for the specified files and directories to the existing state of the permission.
-
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
An entry in the array is not valid.An entry in the array has an invalid format.The parameter is .
@@ -605,22 +563,13 @@
Gets or sets the permitted access to all files.The set of file I/O flags for all files.
- value can be checked for using a bitwise AND operation.
-
-
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet3":::
-
+ value can be checked for using a bitwise AND operation.
+
]]>
@@ -658,22 +607,13 @@
Gets or sets the permitted access to all local files.The set of file I/O flags for all local files.
- value can be checked for using a bitwise AND operation.
-
-
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermission Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermission Example/VB/source.vb" id="Snippet1":::
-
+ value can be checked for using a bitwise AND operation.
+
]]>
@@ -712,11 +652,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -771,11 +711,11 @@
if the specified is equal to the current object; otherwise, .
- .
-
+ .
+
]]>
@@ -823,10 +763,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not compatible.
@@ -869,11 +809,11 @@
Gets a hash code for the object that is suitable for use in hashing algorithms and data structures such as a hash table.A hash code for the current object.
- objects.
-
+ objects.
+
]]>
@@ -921,30 +861,21 @@
Gets all files and directories with the specified .An array containing the paths of the files and directories to which access specified by the parameter is granted.
- [!NOTE]
-> The `access` parameter is limited to the values of , which represent single types of file access. Those values are , , , and . The values acceptable to `access` do not include and , which do not represent single types of file access.
-
-
-
-## Examples
- The following code example shows the use of the method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb" id="Snippet7":::
-
+> The `access` parameter is limited to the values of , which represent single types of file access. Those values are , , , and . The values acceptable to `access` do not include and , which do not represent single types of file access.
+
]]>
- is not a valid value of .
-
- -or-
-
+ is not a valid value of .
+
+ -or-
+
is , which represents more than one type of file access, or , which does not represent any type of file access.
@@ -985,11 +916,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- The parameter is not and is not of the same type as the current permission.
@@ -1033,11 +964,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- The parameter is not and is not of the same type as the current permission.
@@ -1081,11 +1012,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -1137,41 +1068,15 @@
A bitwise combination of the values.
The absolute path of the file or directory.
Sets the specified access to the specified file or directory, replacing the existing state of the permission.
-
- .
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp" id="Snippet12":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs" id="Snippet12":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb" id="Snippet12":::
-
- This access will not be overwritten by the following code because the access types are not the same.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp" id="Snippet13":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs" id="Snippet13":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb" id="Snippet13":::
-
-
-
-## Examples
- The following code example shows the use of the method.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb" id="Snippet7":::
-
- ]]>
-
- The parameter is not a valid value of .
-
- -or-
-
- The parameter is not a valid string.
-
- -or-
-
+ To be added.
+ The parameter is not a valid value of .
+
+ -or-
+
+ The parameter is not a valid string.
+
+ -or-
+
The parameter did not specify the absolute path to the file or directory.
@@ -1212,24 +1117,11 @@
A bitwise combination of the values.
An array containing the absolute paths of the files and directories.
Sets the specified access to the specified files and directories, replacing the current state for the specified access with the new set of paths.
-
- .
-
- This access will not be overwritten by the following code because the access types are not the same.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp" id="Snippet15":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs" id="Snippet15":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb" id="Snippet15":::
-
- ]]>
-
- The parameter is not a valid value of .
-
- -or-
-
+ To be added.
+ The parameter is not a valid value of .
+
+ -or-
+
An entry in the parameter is not a valid string.
@@ -1306,11 +1198,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
+ is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/FileIOPermissionAttribute.xml b/xml/System.Security.Permissions/FileIOPermissionAttribute.xml
index 5c90868ecf0..b3a8e4022d0 100644
--- a/xml/System.Security.Permissions/FileIOPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/FileIOPermissionAttribute.xml
@@ -53,34 +53,21 @@
Allows security actions for to be applied to code using declarative security. This class cannot be inherited.
- that is used.
-
- The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
-
+ Files and directories are specified using absolute paths. When accessing files, a security check is performed when the file is created or opened. The security check is not done again unless the file is closed and reopened. Checking permissions when the file is first accessed minimizes the impact of the security check on application performance because opening a file happens only once, while reading and writing can happen multiple times.
+
+ The scope of the declaration that is allowed depends on the that is used.
+
+ The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
+
> [!CAUTION]
-> `Unrestricted` grants permission for all paths within a file system, including multiple pathnames that can be used to access a single given file. To access to a file, you must `Deny` all possible paths to the file. For example, if \\\server\share is mapped to the network drive X, to `Deny` access to \\\server\share\file, you must `Deny` \\\server\share\file, X:\file and any other path that you can use to access the file.
-
-## Examples
- The following code example demonstrates how to request by using the class, indicating the only permission that is to be granted to the code.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb" id="Snippet1":::
-
- The following example shows how to demand that the calling code has unrestricted . You typically make demands in managed libraries (DLLs) to help protect methods or classes from potentially harmful code.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/Overview/source.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb" id="Snippet2":::
-
+> `Unrestricted` grants permission for all paths within a file system, including multiple pathnames that can be used to access a single given file. To access to a file, you must `Deny` all possible paths to the file. For example, if \\\server\share is mapped to the network drive X, to `Deny` access to \\\server\share\file, you must `Deny` \\\server\share\file, X:\file and any other path that you can use to access the file.
+
]]>
@@ -120,18 +107,7 @@
One of the values.
Initializes a new instance of the class with the specified .
-
- class to set varying levels of file I/O permissions.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet1":::
-
- ]]>
-
+ To be added.The parameter is not a valid .
@@ -178,20 +154,11 @@
Gets or sets full access for the file or directory that is specified by the string value.The absolute path of the file or directory for full access.
- property to grant full access to the specified directory.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet6":::
-
+ The get method is not supported for this property.
@@ -229,13 +196,13 @@
Gets or sets the permitted access to all files.A bitwise combination of the values that represents the permissions for all files. The default is .
- value can be determined by using a bitwise `AND` operation.
-
+ value can be determined by using a bitwise `AND` operation.
+
]]>
@@ -272,13 +239,13 @@
Gets or sets the permitted access to all local files.A bitwise combination of the values that represents the permissions for all local files. The default is .
- value can be determined by using a bitwise `AND` operation.
-
+ value can be determined by using a bitwise `AND` operation.
+
]]>
@@ -316,20 +283,11 @@
Gets or sets append access for the file or directory that is specified by the string value.The absolute path of the file or directory for append access.
- property to grant access to files in the specified directory.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet4":::
-
+
@@ -366,14 +324,14 @@
Gets or sets the file or directory in which access control information can be changed.The absolute path of the file or directory in which access control information can be changed.
- attributes to specify additional files and directories.
-
+ attributes to specify additional files and directories.
+
> [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to change an ACL is an important permission and should be granted with caution.
+
]]>
@@ -412,13 +370,13 @@
Creates and returns a new .A that corresponds to this attribute.
- The path information for a file or directory for which access is to be secured contains invalid characters or wildcard specifiers.
@@ -457,25 +415,16 @@
Gets or sets the file or directory to which to grant path discovery.The absolute path of the file or directory.
- [!NOTE]
-> For performance reasons, should be granted only to directories, not to files. For example, permission should be granted to paths such as C:\test and C:\test\\, not to files such as C:\test\example.txt.
-
- This property sets access for a single file or directory. Use additional attributes to specify additional files and directories.
-
-
-
-## Examples
- The following code example sets the property to grant access to files in the specified directory.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet3":::
-
+> For performance reasons, should be granted only to directories, not to files. For example, permission should be granted to paths such as C:\test and C:\test\\, not to files such as C:\test\example.txt.
+
+ This property sets access for a single file or directory. Use additional attributes to specify additional files and directories.
+
]]>
@@ -513,20 +462,11 @@
Gets or sets read access for the file or directory specified by the string value.The absolute path of the file or directory for read access.
- property to grant access to files in the specified directory.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet2":::
-
+
@@ -563,14 +503,14 @@
Gets or sets the file or directory in which access control information can be viewed.The absolute path of the file or directory in which access control information can be viewed.
- attributes to specify additional files and directories.
-
+ attributes to specify additional files and directories.
+
> [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to view an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the given file and its properties. The ability to view an ACL is an important permission and should be granted with caution.
+
]]>
@@ -607,14 +547,14 @@
Gets or sets the file or directory in which file data can be viewed and modified.The absolute path of the file or directory in which file data can be viewed and modified.
- , , , and properties for a single file or directory. Use additional attributes to specify additional files and directories. The access rights are for file data only; they do not include the access control properties and .
-
+ , , , and properties for a single file or directory. Use additional attributes to specify additional files and directories. The access rights are for file data only; they do not include the access control properties and .
+
> [!NOTE]
-> The `get` accessor is provided for C# compiler compatibility. The C# compiler requires attribute properties to be read/write.
-
+> The `get` accessor is provided for C# compiler compatibility. The C# compiler requires attribute properties to be read/write.
+
]]>The accessor is called. The accessor is provided only for C# compiler compatibility.
@@ -653,20 +593,11 @@
Gets or sets write access for the file or directory specified by the string value.The absolute path of the file or directory for write access.
- property to grant access to files in the specified directory.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/.ctor/fileiopermissionattribute.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb" id="Snippet5":::
-
+
diff --git a/xml/System.Security.Permissions/GacIdentityPermission.xml b/xml/System.Security.Permissions/GacIdentityPermission.xml
index b18d5f2be6d..c545d5c79ff 100644
--- a/xml/System.Security.Permissions/GacIdentityPermission.xml
+++ b/xml/System.Security.Permissions/GacIdentityPermission.xml
@@ -48,19 +48,19 @@
Defines the identity permission for files originating in the global assembly cache. This class cannot be inherited.
- objects are equal.
-
+ Files are either in the global assembly cache, or they are not. There are no variations to the permission granted, so all objects are equal.
+
> [!IMPORTANT]
-> Starting with .NET Framework 4, identity permissions are not used.
->
-> In .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
+> Starting with .NET Framework 4, identity permissions are not used.
+>
+> In .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
]]>
@@ -103,20 +103,11 @@
Initializes a new instance of the class.
- with a value of .
-
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/GacIdentityPermission/.ctor/gacidentitypermission.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb" id="Snippet9":::
-
+ with a value of .
+
]]>
@@ -153,22 +144,13 @@
One of the values.
Initializes a new instance of the class with fully restricted .
- [!NOTE]
-> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface.
-
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/GacIdentityPermission/.ctor/gacidentitypermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb" id="Snippet7":::
-
+> Starting with .NET Framework version 2.0, identity permissions can have any permission state value. This means that identity permissions have the same behavior as permissions that implement the interface.
+
]]>
@@ -208,11 +190,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -252,20 +234,20 @@
A that contains the XML encoding to use to create the permission.
Creates a permission from an XML encoding.
- method creates a from an XML encoding defined by a object. Use the method to XML-encode the , including state information.
-
+ method creates a from an XML encoding defined by a object. Use the method to XML-encode the , including state information.
+
]]> is .
- is not a valid permission element.
-
- -or-
-
+ is not a valid permission element.
+
+ -or-
+
The version number of is not valid.
@@ -305,13 +287,13 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. The new permission is if the intersection is empty.
- only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
-
+ only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
+
]]>
@@ -355,13 +337,13 @@
if the current permission is a subset of the specified permission; otherwise, .
- only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
-
+ only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
+
]]>
@@ -401,11 +383,11 @@
Creates an XML encoding of the permission and its current state.A that represents the XML encoding of the permission, including any state information.
- method to create a from a .
-
+ method to create a from a .
+
]]>
@@ -446,13 +428,13 @@
Creates and returns a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- method is a permission that includes all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
- A only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
-
+ method is a permission that includes all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
+ A only supports set operations (the , , and methods) when the current permission is equal to the specified permission.
+
]]>
diff --git a/xml/System.Security.Permissions/GacIdentityPermissionAttribute.xml b/xml/System.Security.Permissions/GacIdentityPermissionAttribute.xml
index 87a0a1ab7f7..ce8d3a89e5e 100644
--- a/xml/System.Security.Permissions/GacIdentityPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/GacIdentityPermissionAttribute.xml
@@ -52,32 +52,25 @@
Allows security actions for to be applied to code using declarative security. This class cannot be inherited.
- value that is used.
-
- The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class, .
-
+ This class is used to ensure that callers are registered in the global assembly cache (GAC).
+
+ The scope of the declaration that is allowed depends on the value that is used.
+
+ The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class, .
+
> [!IMPORTANT]
-> Starting with the .NET Framework 4, identity permissions are not used.
->
-> In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. In the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
+> Starting with .NET Framework 4, identity permissions aren't used.
+>
+> Demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
For more information about using attributes, see [Attributes](/dotnet/standard/attributes/).
-
-## Examples
- The following example demonstrates the use of .
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/GacIdentityPermissionAttribute/Overview/gacidentitypermissionattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb" id="Snippet1":::
-
+
]]>
@@ -114,24 +107,15 @@
One of the values.
Initializes a new instance of the class with the specified value.
- value.
-
- This constructor associates a (for example, `Demand`) with the .
-
- The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. Use for imperative security.
-
-
-
-## Examples
- The following code example demonstrates the use of the constructor to demand that the calling program be in the global assembly cache. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/GacIdentityPermissionAttribute/Overview/gacidentitypermissionattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb" id="Snippet2":::
-
+ value.
+
+ This constructor associates a (for example, `Demand`) with the .
+
+ The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. Use for imperative security.
+
]]>The parameter is not a valid value.
@@ -170,13 +154,13 @@
Creates a new object.A that corresponds to this attribute.
-
diff --git a/xml/System.Security.Permissions/HostProtectionAttribute.xml b/xml/System.Security.Permissions/HostProtectionAttribute.xml
index ef3bf327219..e152a3b4358 100644
--- a/xml/System.Security.Permissions/HostProtectionAttribute.xml
+++ b/xml/System.Security.Permissions/HostProtectionAttribute.xml
@@ -61,30 +61,21 @@
This attribute affects only unmanaged applications that host the common language runtime and implement host protection, such as SQL Server. If the code is run in a client application or on a server that is not host-protected, the attribute "evaporates"; it is not detected and therefore not applied. When applied, the security action results in the creation of a link demand based on the host resources the class or method exposes.
> [!IMPORTANT]
-> The purpose of this attribute is to enforce host-specific programming model guidelines, not security behavior. Although a link demand is used to check for conformance to programming model requirements, the is not a security permission.
+> The purpose of this attribute is to enforce host-specific programming model guidelines, not security behavior. Although a link demand is used to check for conformance to programming model requirements, the is not a security permission.
If the host does not have programming model requirements, the link demands do not occur.
This attribute identifies the following:
- Methods or classes that do not fit the host programming model, but are otherwise benign.
-
- Methods or classes that do not fit the host programming model and could lead to destabilizing server-managed user code.
-
- Methods or classes that do not fit the host programming model and could lead to a destabilization of the server process itself.
> [!NOTE]
-> If you are creating a class library that is to be called by applications that may execute in a host protected environment, you should apply this attribute to members that expose resource categories. The .NET Framework class library members with this attribute cause only the immediate caller to be checked. Your library member must also cause a check of its immediate caller in the same manner.
+> If you are creating a class library that is to be called by applications that may execute in a host protected environment, you should apply this attribute to members that expose resource categories. The .NET Framework class library members with this attribute cause only the immediate caller to be checked. Your library member must also cause a check of its immediate caller in the same manner.
> [!NOTE]
-> Do not use the [Ngen.exe (Native Image Generator)](/dotnet/framework/tools/ngen-exe-native-image-generator) to create a native image of assemblies that are protected by the . In a full-trust environment, the image is always loaded, without regard to the , and in a partial-trust environment the image is not loaded.
-
-## Examples
- The following code example illustrates the use of the attribute with a variety of values.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet1":::
+> Do not use the [Ngen.exe (Native Image Generator)](/dotnet/framework/tools/ngen-exe-native-image-generator) to create a native image of assemblies that are protected by the . In a full-trust environment, the image is always loaded, without regard to the , and in a partial-trust environment the image is not loaded.
]]>
@@ -270,15 +261,6 @@
## Remarks
Code that exposes external process management might create or destroy other processes.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet5":::
-
]]>
@@ -322,15 +304,6 @@
## Remarks
Code that exposes external threading creates or manipulates threads other than its own, which might be harmful to the host.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet6":::
-
]]>
@@ -416,15 +389,6 @@
## Remarks
The flags specify the resources exposed by the method or class that are potentially harmful to the host.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet2":::
-
]]>
@@ -474,15 +438,6 @@
## Remarks
The use of a object to impersonate a user is an example of exposing the security infrastructure.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet4":::
-
]]>
@@ -526,15 +481,6 @@
## Remarks
Self-affecting process management code might exit the current process, terminating the server.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet2":::
-
]]>
@@ -578,15 +524,6 @@
## Remarks
Self-affecting threading manipulates threads in a way that only affects user code.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet3":::
-
]]>
@@ -630,15 +567,6 @@
## Remarks
When is `true`, it indicates that a state is exposed that might be shared between threads.
-
-
-## Examples
- The following code example illustrates the use of the attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet3":::
-
]]>
@@ -676,18 +604,7 @@
Gets or sets a value indicating whether synchronization is exposed. if synchronization is exposed; otherwise, . The default is .
-
- attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet6":::
-
- ]]>
-
+ To be added.
@@ -723,18 +640,7 @@
Gets or sets a value indicating whether the user interface is exposed. if the user interface is exposed; otherwise, . The default is .
-
- attribute with the property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet3":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Permissions/HostProtectionResource.xml b/xml/System.Security.Permissions/HostProtectionResource.xml
index fa52caee78a..866c64c7b29 100644
--- a/xml/System.Security.Permissions/HostProtectionResource.xml
+++ b/xml/System.Security.Permissions/HostProtectionResource.xml
@@ -55,21 +55,14 @@
Specifies categories of functionality potentially harmful to the host if invoked by a method or class.
- attribute.
-
-## Examples
- The following code example shows the use of the enumeration with the attribute. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/HostProtectionAttribute/Overview/hostprotectionattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb" id="Snippet2":::
-
+
]]>
diff --git a/xml/System.Security.Permissions/IUnrestrictedPermission.xml b/xml/System.Security.Permissions/IUnrestrictedPermission.xml
index f9a0001770d..1c198619c17 100644
--- a/xml/System.Security.Permissions/IUnrestrictedPermission.xml
+++ b/xml/System.Security.Permissions/IUnrestrictedPermission.xml
@@ -42,25 +42,14 @@
Allows a permission to expose an unrestricted state.
- .
-
-## Examples
- This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented.
-
- The following code example demonstrates the behavior of the methods.
-
- The example is intended to show how the methods perform if you execute the methods from your code. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1":::
-
+
]]>
@@ -99,18 +88,7 @@
Returns a value indicating whether unrestricted access to the resource protected by the permission is allowed. if unrestricted use of the resource protected by the permission is allowed; otherwise, .
-
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet8":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet8":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Permissions/IsolatedStorageContainment.xml b/xml/System.Security.Permissions/IsolatedStorageContainment.xml
index 12a43fe2176..a52ce7a5ce0 100644
--- a/xml/System.Security.Permissions/IsolatedStorageContainment.xml
+++ b/xml/System.Security.Permissions/IsolatedStorageContainment.xml
@@ -48,43 +48,34 @@
Specifies the permitted use of isolated storage.
- , , and .
-
- These identities are grouped together, in which case the identities are applied one after another until the desired isolated storage is created. The valid groupings are User+Assembly and User+Assembly+Domain. This grouping of identities is useful in many different applications.
-
- If data is stored by domain, user, and assembly, the data is private in that only code in that assembly can access the data. The data store is also isolated by the application in which it runs, so that the assembly does not represent a potential leak by exposing data to other applications.
-
- Isolation by assembly and user could be used for user data that applies across multiple applications; for example, license information, or a user's personal information (name, authentication credentials, and so on) that is independent of an application.
-
- exposes flags that determine whether an application is allowed to use isolated storage and, if so, which identity combinations are allowed to use it. It also determines whether an application is allowed to store information in a location that can roam with a user (Windows Roaming User Profiles or Folder Redirection must be configured).
-
-
-
-## Examples
- This example shows how to tell the CLR that code in this assembly requires the and also demonstrates how to write and read from isolated storage.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/IsolatedStorageContainment/Overview/IsolatedStoragePermissionAttribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb" id="Snippet1":::
-
+ Isolated storage uses evidence to determine a unique storage area for use by an application or component. The identity of an assembly uniquely determines the root of a virtual file system for use by that assembly. Thus, rather than many applications and components sharing a common resource such as the file system or registry, each has its own file area inherently assigned to it.
+
+ Four basic isolation scopes are used when assigning isolated storage:
+
+- `User` - Code is always scoped according to the current user. The same assembly will receive different stores when being run by different users.
+
+- `Machine` - Code is always scoped according to the machine. The same assembly will receive the same stores when being run by different users on the same machine.
+
+- `Assembly` - Code is identified cryptographically by strong name (for example, Microsoft.Office.\* or Microsoft.Office.Word), by publisher (based on public key), by URL (for example, `http://www.fourthcoffee.com/process/grind.htm`), by site, or by zone.
+
+- `Domain` - Code is identified based on evidence associated with the application domain. Web application identity is derived from the site's URL, or by the Web page's URL, site, or zone. Local code identity is based on the application directory path.
+
+ For definitions of URL, site, and zone, see , , and .
+
+ These identities are grouped together, in which case the identities are applied one after another until the desired isolated storage is created. The valid groupings are User+Assembly and User+Assembly+Domain. This grouping of identities is useful in many different applications.
+
+ If data is stored by domain, user, and assembly, the data is private in that only code in that assembly can access the data. The data store is also isolated by the application in which it runs, so that the assembly does not represent a potential leak by exposing data to other applications.
+
+ Isolation by assembly and user could be used for user data that applies across multiple applications; for example, license information, or a user's personal information (name, authentication credentials, and so on) that is independent of an application.
+
+ exposes flags that determine whether an application is allowed to use isolated storage and, if so, which identity combinations are allowed to use it. It also determines whether an application is allowed to store information in a location that can roam with a user (Windows Roaming User Profiles or Folder Redirection must be configured).
+
]]>
diff --git a/xml/System.Security.Permissions/KeyContainerPermission.xml b/xml/System.Security.Permissions/KeyContainerPermission.xml
index 3593d20dac8..8c2d3e0bb96 100644
--- a/xml/System.Security.Permissions/KeyContainerPermission.xml
+++ b/xml/System.Security.Permissions/KeyContainerPermission.xml
@@ -52,14 +52,14 @@
Controls the ability to access key containers. This class cannot be inherited.
-
@@ -107,18 +107,7 @@
A bitwise combination of the values.
Initializes a new instance of the class with the specified access.
-
- constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet20":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet20":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet20":::
-
- ]]>
-
+ To be added. is not a valid combination of the values.
@@ -155,11 +144,11 @@
One of the values.
Initializes a new instance of the class with either restricted or unrestricted permission.
-
@@ -199,18 +188,7 @@
A bitwise combination of the values.
An array of objects identifying specific key container access rights.
Initializes a new instance of the class with the specified global access and specific key container access rights.
-
- constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet13":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet13":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet13":::
-
- ]]>
-
+ To be added. is not a valid combination of the values.
@@ -249,11 +227,11 @@
Gets the collection of objects associated with the current permission.A containing the objects for this .
- object in the collection specifies the access rights for a specific key container.
-
+ object in the collection specifies the access rights for a specific key container.
+
]]>
@@ -291,11 +269,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -332,11 +310,11 @@
Gets the key container permission flags that apply to all key containers associated with the permission.A bitwise combination of the values.
- property is set by the constructor.
-
+ property is set by the constructor.
+
]]>
@@ -376,20 +354,20 @@
A that contains the XML encoding used to reconstruct the permission.
Reconstructs a permission with a specified state from an XML encoding.
- method reconstructs a object from an XML encoding defined by the class. Use the method to XML-encode the , including state information.
-
+ method reconstructs a object from an XML encoding defined by the class. Use the method to XML-encode the , including state information.
+
]]> is .
- is not a valid permission element.
-
- -or-
-
+ is not a valid permission element.
+
+ -or-
+
The version number of is not supported.
@@ -429,11 +407,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
-
@@ -477,11 +455,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- access is a subset of a permission for access.
-
+ access is a subset of a permission for access.
+
]]>
@@ -525,11 +503,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -567,11 +545,11 @@
Creates an XML encoding of the permission and its current state.A that contains an XML encoding of the permission, including state information.
- method to restore the state information from a .
-
+ method to restore the state information from a .
+
]]>
@@ -612,11 +590,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
+ is a permission that represents all operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>
diff --git a/xml/System.Security.Permissions/KeyContainerPermissionAccessEntry.xml b/xml/System.Security.Permissions/KeyContainerPermissionAccessEntry.xml
index 41f09f48825..fd3563a54f4 100644
--- a/xml/System.Security.Permissions/KeyContainerPermissionAccessEntry.xml
+++ b/xml/System.Security.Permissions/KeyContainerPermissionAccessEntry.xml
@@ -48,14 +48,14 @@
Specifies access rights for specific key containers. This class cannot be inherited.
-
@@ -104,20 +104,11 @@
A bitwise combination of the values.
Initializes a new instance of the class, using the specified cryptographic service provider (CSP) parameters and access permissions.
- object.
-
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet3":::
-
+ object.
+
]]>The resulting entry would have unrestricted access.
@@ -157,20 +148,11 @@
A bitwise combination of the values.
Initializes a new instance of the class, using the specified key container name and access permissions.
- constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet2":::
-
+ The resulting entry would have unrestricted access.
@@ -218,20 +200,11 @@
A bitwise combination of the values.
Initializes a new instance of the class with the specified property values.
- constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet4":::
-
+ The resulting entry would have unrestricted access.
@@ -274,11 +247,11 @@
if the specified is equal to the current object; otherwise, .
- method compares the properties of the two objects to determine if they are equal.
-
+ method compares the properties of the two objects to determine if they are equal.
+
]]>
@@ -315,15 +288,15 @@
Gets or sets the key container permissions.A bitwise combination of the values. The default is .
- [!CAUTION]
-> Many of these flags are powerful and permit access to key containers that should only be granted to highly trusted code.
-
- The most powerful of the flags are , , , , , , and . For specific threats posed by the use of these flags, see individual flag descriptions.
-
+> Many of these flags are powerful and permit access to key containers that should only be granted to highly trusted code.
+
+ The most powerful of the flags are , , , , , , and . For specific threats posed by the use of these flags, see individual flag descriptions.
+
]]>
@@ -361,11 +334,11 @@
Gets a hash code for the current instance that is suitable for use in hashing algorithms and data structures such as a hash table.A hash code for the current object.
- , suitable for use in hashing algorithms and data structures such as a hash table.
-
+ , suitable for use in hashing algorithms and data structures such as a hash table.
+
]]>
@@ -402,11 +375,11 @@
Gets or sets the key container name.The name of the key container.
- The resulting entry would have unrestricted access.
@@ -444,11 +417,11 @@
Gets or sets the key specification.One of the AT_ values defined in the Wincrypt.h header file.
- The resulting entry would have unrestricted access.
@@ -486,11 +459,11 @@
Gets or sets the name of the key store.The name of the key store.
- The resulting entry would have unrestricted access.
@@ -528,11 +501,11 @@
Gets or sets the provider name.The name of the provider.
- The resulting entry would have unrestricted access.
@@ -570,49 +543,49 @@
Gets or sets the provider type.One of the PROV_ values defined in the Wincrypt.h header file.
- The resulting entry would have unrestricted access.
diff --git a/xml/System.Security.Permissions/KeyContainerPermissionFlags.xml b/xml/System.Security.Permissions/KeyContainerPermissionFlags.xml
index b892ea639fa..f963d0271c8 100644
--- a/xml/System.Security.Permissions/KeyContainerPermissionFlags.xml
+++ b/xml/System.Security.Permissions/KeyContainerPermissionFlags.xml
@@ -51,27 +51,19 @@
Specifies the type of key container access allowed.
- class.
-
+ This enumeration is used by members of the class.
+
> [!CAUTION]
> Many of these flags can have powerful effects and should be granted only to highly trusted code.
->
+>
> The most powerful flags are `Create`, `Delete`, `Import`, `Export`, `Sign`, `Decrypt`, and `AllFlags`. For specific threats that the use of these flags can present, see the member descriptions.
-## Examples
-
-The following example shows the use of the `KeyContainerPermissionFlags` enumeration.
-
-:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp" id="Snippet20":::
-:::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/KeyContainerPermission/.ctor/keycontainerpermission.cs" id="Snippet20":::
-:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb" id="Snippet20":::
-
]]>
diff --git a/xml/System.Security.Permissions/MediaPermission.xml b/xml/System.Security.Permissions/MediaPermission.xml
index c3030740b4d..a781f852b04 100644
--- a/xml/System.Security.Permissions/MediaPermission.xml
+++ b/xml/System.Security.Permissions/MediaPermission.xml
@@ -54,14 +54,14 @@
The describes a set of security permissions that controls the ability for audio, image, and video media to work in a partial-trust Windows Presentation Foundation (WPF) application.
- , , and enumerations.
-
+ This permission uses the values of the , , and enumerations.
+
]]>
@@ -135,19 +135,11 @@
An enumerated value of .
Initializes a new instance of the class by specifying the audio permission level.
- and .
-
-
-
-## Examples
- The following code example shows how to create a with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission1":::
-
+ and .
+
]]>
@@ -183,19 +175,11 @@
An enumerated value of .
Initializes a new instance of the class by specifying the image permission level.
- and .
-
-
-
-## Examples
- The following code example shows how to create a with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission2":::
-
+ and .
+
]]>
@@ -231,19 +215,11 @@
An enumerated value of .
Initializes a new instance of the class by specifying the video permission level.
- and .
-
-
-
-## Examples
- The following code example shows how to create a with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission3":::
-
+ and .
+
]]>
@@ -279,19 +255,11 @@
An enumerated value of .
Initializes a new instance of the class by specifying a permission state.
- , all media types are granted full permission to play or display with no restrictions. If `state` is set to , all media types are restricted from playing or displaying.
-
-
-
-## Examples
- The following code example shows how to create a with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission4":::
-
+ , all media types are granted full permission to play or display with no restrictions. If `state` is set to , all media types are restricted from playing or displaying.
+
]]>
@@ -330,17 +298,7 @@
An enumerated value of .
An enumerated value of .
Initializes a new instance of the class by specifying the audio, video, and image permission levels.
-
- with , , and values
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission5":::
-
- ]]>
-
+ To be added.
@@ -379,17 +337,7 @@
Gets the current value of the audio permission level.The audio permission level.
-
- value for the .
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission6":::
-
- ]]>
-
+ To be added.
@@ -424,11 +372,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -505,17 +453,7 @@
Gets the current value of the image permission level.The image permission level.
-
- value for the .
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission7":::
-
- ]]>
-
+ To be added.
@@ -591,13 +529,13 @@
if the current permission is a subset of the specified permission; otherwise, .
-
@@ -644,19 +582,11 @@
if the audio, image, and video permissions are all unrestricted; otherwise, .
- , , and .
-
-
-
-## Examples
- The following code example shows how to determine whether the is unrestricted.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission16":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission16":::
-
+ , , and .
+
]]>
@@ -768,17 +698,7 @@
Gets the current value of the video permission level.The media permission level.
-
- value for the .
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermission8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermission8":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Permissions/MediaPermissionAttribute.xml b/xml/System.Security.Permissions/MediaPermissionAttribute.xml
index 8d43062841a..2a994b43779 100644
--- a/xml/System.Security.Permissions/MediaPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/MediaPermissionAttribute.xml
@@ -49,22 +49,16 @@
Allows security actions for to be applied to code using declarative security.
- controls the ability for audio, image, and video media to work in a partial-trust Windows Presentation Foundation (WPF) application. The scope of the declaration that is allowed depends on the that is used.
-
+ controls the ability for audio, image, and video media to work in a partial-trust Windows Presentation Foundation (WPF) application. The scope of the declaration that is allowed depends on the that is used.
+
The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class, .
-
-## Examples
- The following example shows how to demand that the calling code has unrestricted at link time. Demands are typically made in managed libraries (DLLs) to help protect methods or classes from potentially harmful code.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute1":::
-
+
]]>Extending Metadata Using Attributes
@@ -107,19 +101,11 @@
One of the values.
Initializes a new instance of .
- , , and .
-
-
-
-## Examples
- The following code example shows how to create a .
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute13":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute13":::
-
+ , , and .
+
]]>
@@ -161,19 +147,11 @@
Gets or sets the audio permission level for the .The state of the .
- .
-
-
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute4":::
-
+ .
+
]]>
@@ -210,13 +188,13 @@
Creates and returns a new .A that corresponds to this attribute.
-
@@ -258,19 +236,11 @@
Gets or sets the image permission level for the .The state of the .
- .
-
-
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute5":::
-
+ .
+
]]>
@@ -312,19 +282,11 @@
Gets or sets the video permission level for the .The state of the .
- .
-
-
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute10":::
-
+ .
+
]]>
diff --git a/xml/System.Security.Permissions/MediaPermissionAudio.xml b/xml/System.Security.Permissions/MediaPermissionAudio.xml
index 96f7ed0571d..e37b15b40c3 100644
--- a/xml/System.Security.Permissions/MediaPermissionAudio.xml
+++ b/xml/System.Security.Permissions/MediaPermissionAudio.xml
@@ -44,20 +44,14 @@
Specifies the permission level for audio.
- property of the class. The default is SafeAudio.
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute4":::
-
+
]]>
diff --git a/xml/System.Security.Permissions/MediaPermissionImage.xml b/xml/System.Security.Permissions/MediaPermissionImage.xml
index 825af3111d5..c2c80dfee51 100644
--- a/xml/System.Security.Permissions/MediaPermissionImage.xml
+++ b/xml/System.Security.Permissions/MediaPermissionImage.xml
@@ -44,20 +44,14 @@
Specifies the permission level for images.
- property of the class. The default is SafeImage.
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute5":::
-
+
]]>
diff --git a/xml/System.Security.Permissions/MediaPermissionVideo.xml b/xml/System.Security.Permissions/MediaPermissionVideo.xml
index e1af9ba4e71..c494564e650 100644
--- a/xml/System.Security.Permissions/MediaPermissionVideo.xml
+++ b/xml/System.Security.Permissions/MediaPermissionVideo.xml
@@ -44,20 +44,14 @@
Specifies the permission level for video.
- property of the class. The default is SafeVideo.
-
-## Examples
- The following code example shows the use of the property.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/MediaPermission/.ctor/Window1.xaml.cs" id="Snippetmediapermissionattribute10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/SecurityPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetmediapermissionattribute10":::
-
+
]]>
diff --git a/xml/System.Security.Permissions/PermissionSetAttribute.xml b/xml/System.Security.Permissions/PermissionSetAttribute.xml
index e543f2a0c28..acd73b8862a 100644
--- a/xml/System.Security.Permissions/PermissionSetAttribute.xml
+++ b/xml/System.Security.Permissions/PermissionSetAttribute.xml
@@ -53,24 +53,18 @@
Allows security actions for a to be applied to code using declarative security. This class cannot be inherited.
- properties , , and are mutually exclusive, meaning that a permission set can have as its source only one of the following: a named permission set, a file containing an XML representation of a permission set, or a string containing an XML representation of a permission set.
-
- The scope of the declaration that is allowed depends on the that is used. A performed on a is the equivalent of performing that action on each of the permissions within the set.
-
+ The properties , , and are mutually exclusive, meaning that a permission set can have as its source only one of the following: a named permission set, a file containing an XML representation of a permission set, or a string containing an XML representation of a permission set.
+
+ The scope of the declaration that is allowed depends on the that is used. A performed on a is the equivalent of performing that action on each of the permissions within the set.
+
The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
-
-## Examples
- The following example shows the use of the Class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PermissionSetAttribute/Overview/permissionsetattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb" id="Snippet1":::
-
+
]]>
@@ -147,11 +141,11 @@
This method is not used.A null reference ( in Visual Basic) in all cases.
- .
-
+ .
+
]]>
@@ -196,13 +190,13 @@
Creates and returns a new permission set based on this permission set attribute object.A new permission set.
-
@@ -240,19 +234,11 @@
Gets or sets a file containing the XML representation of a custom permission set to be declared.The physical path to the file containing the XML representation of the permission set.
- property to `true`.
-
-
-
-## Examples
- The following code shows the use of the property. This code example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PermissionSetAttribute/Overview/permissionsetattribute.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb" id="Snippet2":::
-
+ property to `true`.
+
]]>
@@ -324,19 +310,11 @@
Gets or sets the name of the permission set.The name of an immutable (one of several permission sets that are contained in the default policy and cannot be altered).
- property. This code example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PermissionSetAttribute/Overview/permissionsetattribute.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb" id="Snippet3":::
-
+
@@ -375,13 +353,13 @@
if the file is Unicode encoded; otherwise, .
- is `null` this property is not used.
-
+ is `null` this property is not used.
+
]]>
diff --git a/xml/System.Security.Permissions/PrincipalPermission.xml b/xml/System.Security.Permissions/PrincipalPermission.xml
index 3ba94bcf604..a0900148cf7 100644
--- a/xml/System.Security.Permissions/PrincipalPermission.xml
+++ b/xml/System.Security.Permissions/PrincipalPermission.xml
@@ -60,33 +60,23 @@
Allows checks against the active principal (see ) using the language constructs defined for both declarative and imperative security actions. This class cannot be inherited.
- can be used to demand that the identity of the active principal matches this information.
-
- To match the active and associated , both the specified identity and role must match. If `null` identity string is used, it is interpreted as a request to match any identity. Use of `null` role string will match any role. By implication, passing `null` parameter for `name` or `role` to will match the identity and roles in any . It is also possible to construct a that only determines whether the represents an authenticated or unauthenticated entity. In this case, `name` and `role` are ignored.
-
- Unlike most other permissions, does not extend . It does, however, implement the interface. This is because is not a code access permission; that is, it is not granted based on the identity of the executing assembly. Instead, it allows code to perform actions (, , , and so on) against the current user identity in a manner consistent with the way those actions are performed for code access and code identity permissions.
-
+ By passing identity information (user name and role) to the constructor, can be used to demand that the identity of the active principal matches this information.
+
+ To match the active and associated , both the specified identity and role must match. If `null` identity string is used, it is interpreted as a request to match any identity. Use of `null` role string will match any role. By implication, passing `null` parameter for `name` or `role` to will match the identity and roles in any . It is also possible to construct a that only determines whether the represents an authenticated or unauthenticated entity. In this case, `name` and `role` are ignored.
+
+ Unlike most other permissions, does not extend . It does, however, implement the interface. This is because is not a code access permission; that is, it is not granted based on the identity of the executing assembly. Instead, it allows code to perform actions (, , , and so on) against the current user identity in a manner consistent with the way those actions are performed for code access and code identity permissions.
+
> [!IMPORTANT]
-> Prior to a demand for principal permission it is necessary to set the current application domain's principal policy to the enumeration value . By default, the principal policy is set to . If you do not set the principal policy to , a demand for principal permission will fail. The following code should be executed before the principal permission is demanded:
->
-> `AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).`
-
-## Examples
- The following example requires the active principal to be an administrator. The `name` parameter is `null`, which enables any user who is an administrator to pass the demand.
-
-> [!NOTE]
-> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that requires you to be an administrator, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb" id="Snippet1":::
-
+> Prior to a demand for principal permission it is necessary to set the current application domain's principal policy to the enumeration value . By default, the principal policy is set to . If you do not set the principal policy to , a demand for principal permission will fail. The following code should be executed before the principal permission is demanded:
+>
+> `AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).`
+
]]>
@@ -135,14 +125,14 @@
One of the values.
Initializes a new instance of the class with the specified .
- is the empty string (""), no , is `false`). `Unrestricted` matches all principals ( is `null`, is `null`).
-
+ is the empty string (""), no , is `false`). `Unrestricted` matches all principals ( is `null`, is `null`).
+
> [!NOTE]
-> This constructor is included for consistency with the design of other permissions, but is not useful in practice.
-
+> This constructor is included for consistency with the design of other permissions, but is not useful in practice.
+
]]>The parameter is not a valid .
@@ -183,22 +173,11 @@
The role of the object's user (for example, Administrator).
Initializes a new instance of the class for the specified and .
- and associated . Set `name` to `null` to check for any user in a role.
-
-
-
-## Examples
- The following example requires the active principal to be an administrator. The `name` parameter is `null`, which enables any user who is an administrator to pass the demand.
-
- **Note** In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that requires you to be an administrator, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/VB/source.vb" id="Snippet1":::
-
+ and associated . Set `name` to `null` to check for any user in a role.
+
]]>
@@ -241,11 +220,11 @@
to signify that the user is authenticated; otherwise, .
Initializes a new instance of the class for the specified , , and authentication status.
- and associated .
-
+ and associated .
+
]]>
@@ -287,11 +266,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -338,24 +317,24 @@
Determines at run time whether the current principal matches the principal specified by the current permission.
- is raised, succeeds.
-
- This method acts against the principal attached to the calling thread.
-
+ is raised, succeeds.
+
+ This method acts against the principal attached to the calling thread.
+
> [!IMPORTANT]
-> Prior to calling the method, it is necessary to set the current application domain's principal policy to the enumeration value . By default the principal policy is set to . If you do not set the principal policy to , a demand for principal permission will fail. The following code should be executed before the demand for principal permission occurs:
->
-> `AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).`
-
+> Prior to calling the method, it is necessary to set the current application domain's principal policy to the enumeration value . By default the principal policy is set to . If you do not set the principal policy to , a demand for principal permission will fail. The following code should be executed before the demand for principal permission occurs:
+>
+> `AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).`
+
]]>
- The current principal does not pass the security check for the principal specified by the current permission.
-
- -or-
-
+ The current principal does not pass the security check for the principal specified by the current permission.
+
+ -or-
+
The current is .
@@ -409,11 +388,11 @@
if the specified is equal to the current object; otherwise, .
- .
-
+ .
+
]]>
@@ -458,10 +437,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -504,11 +483,11 @@
Gets a hash code for the object that is suitable for use in hashing algorithms and data structures such as a hash table.A hash code for the current object.
- objects.
-
+ objects.
+
]]>
@@ -552,26 +531,7 @@
A permission to intersect with the current permission. It must be of the same type as the current permission.
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission will be if the intersection is empty.
-
- . For example,
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/Intersect/remarks.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb" id="Snippet1":::
-
- is equivalent to
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/Intersect/remarks.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb" id="Snippet2":::
-
- because no identity can simultaneously represent both Bob and Louise. In effect, `pp1.Demand()` only succeeds if an unauthenticated principal (with name equal to the empty string ("")) is allowed to act in the Administrator role.
-
- ]]>
-
+ To be added.The parameter is not and is not an instance of the same class as the current permission.
@@ -616,22 +576,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- corresponding to three distinct users. Two additional instances are then created as groups of users. `pp1` represents Bob and Louise, `pp2` represents Bob, Louise, and Greg.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/IsSubsetOf/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/VB/source.vb" id="Snippet1":::
-
- With the preceding declarations, `pp1.IsSubsetOf(pp2)` returns `true`, and `pp2.IsSubsetOf(pp1)` returns `false`.
-
+ The parameter is an object that is not of the same type as the current permission.
@@ -675,11 +624,11 @@
if the current permission is unrestricted; otherwise, .
- matches any principal.
-
+ matches any principal.
+
]]>
@@ -798,20 +747,7 @@
A permission to combine with the current permission. It must be of the same type as the current permission.
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
-
- creates a permission representing the criteria of a given set of individual objects. It is useful for compactly representing a set of conditions to test. For example, with the declarations
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermission/Intersect/remarks.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb" id="Snippet3":::
-
- `(ppBob.Union(ppLouise)).Demand()` will succeed if the current principal represents Bob in the role of Administrator or Louise in the role of Administrator.
-
- ]]>
-
+ To be added.The parameter is an object that is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/PrincipalPermissionAttribute.xml b/xml/System.Security.Permissions/PrincipalPermissionAttribute.xml
index 1626a97834b..c8209530cd4 100644
--- a/xml/System.Security.Permissions/PrincipalPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/PrincipalPermissionAttribute.xml
@@ -53,31 +53,21 @@
Allows security actions for to be applied to code using declarative security. This class cannot be inherited.
- can be used to declaratively demand that users running your code belong to a specified role or have been authenticated. Use of creates a with set to `true` and and set to `null`.
-
- The scope of the declaration that is allowed depends on the that is used. cannot be applied at the assembly level.
-
- The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
-
+ can be used to declaratively demand that users running your code belong to a specified role or have been authenticated. Use of creates a with set to `true` and and set to `null`.
+
+ The scope of the declaration that is allowed depends on the that is used. cannot be applied at the assembly level.
+
+ The security information declared by a security attribute is stored in the metadata of the attribute target and is accessed by the system at run time. Security attributes are used only for declarative security. For imperative security, use the corresponding permission class.
+
> [!IMPORTANT]
> Before you use this class to demand principal permission, you must set the current application domain's principal policy to the enumeration value . By default, the principal policy is set to . If you do not set the principal policy to , a demand for principal permission will fail. The following code should be executed before the principal permission is demanded: `AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal).`
-
-## Examples
- The following example demonstrates how the class is used declaratively to demand that the current user be an administrator.
-
-> [!NOTE]
-> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that requires you to be an administrator, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermissionAttribute/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb" id="Snippet1":::
-
+
]]>
@@ -123,23 +113,11 @@
One of the values.
Initializes a new instance of the class with the specified .
- that have meaning for this attribute. Other actions do not apply to permissions that are not code access permissions.
-
-
-
-## Examples
- The following example demonstrates how to use the constructor to demand that the current user be an administrator.
-
-> [!NOTE]
-> In Windows Vista, User Account Control (UAC) determines the privileges of a user. If you are a member of the Built-in Administrators group, you are assigned two run-time access tokens: a standard user access token and an administrator access token. By default, you are in the standard user role. To execute the code that requires you to be an administrator, you must first elevate your privileges from standard user to administrator. You can do this when you start an application by right-clicking the application icon and indicating that you want to run as an administrator.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PrincipalPermissionAttribute/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/VB/source.vb" id="Snippet1":::
-
+ that have meaning for this attribute. Other actions do not apply to permissions that are not code access permissions.
+
]]>
@@ -214,13 +192,13 @@
Creates and returns a new .A that corresponds to this attribute.
-
@@ -258,11 +236,11 @@
Gets or sets the name of the identity associated with the current principal.A name to match against that provided by the underlying role-based security provider.
- is the same as the user's Windows NT login name (in the form "DomainName\UserName"). Check the documentation of your host to determine which authentication provider it uses and how it determines the identity of the current principal.
-
+ is the same as the user's Windows NT login name (in the form "DomainName\UserName"). Check the documentation of your host to determine which authentication provider it uses and how it determines the identity of the current principal.
+
]]>
@@ -300,11 +278,11 @@
Gets or sets membership in a specified security role.The name of a role from the underlying role-based security provider.
-
diff --git a/xml/System.Security.Permissions/PublisherIdentityPermission.xml b/xml/System.Security.Permissions/PublisherIdentityPermission.xml
index 74a6d36c336..8367e166cbe 100644
--- a/xml/System.Security.Permissions/PublisherIdentityPermission.xml
+++ b/xml/System.Security.Permissions/PublisherIdentityPermission.xml
@@ -49,22 +49,22 @@
Represents the identity of a software publisher. This class cannot be inherited.
- [!IMPORTANT]
-> Starting with the .NET Framework 4, identity permissions are not used.
->
-> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
->
-> In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
+> Starting with the .NET Framework 4, identity permissions are not used.
+>
+> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
+>
+> In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
> [!NOTE]
-> By default, code access security does not check for evidence. Unless your computer has a custom code group based on the class, you can improve performance by bypassing Authenticode signature verification. This is accomplished by configuring the runtime to not provide evidence for code access security. For more information about how to configure this option and which applications can use it, see the [<generatePublisherEvidence>](/dotnet/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element) element.
-
+> By default, code access security does not check for evidence. Unless your computer has a custom code group based on the class, you can improve performance by bypassing Authenticode signature verification. This is accomplished by configuring the runtime to not provide evidence for code access security. For more information about how to configure this option and which applications can use it, see the [<generatePublisherEvidence>](/dotnet/framework/configure-apps/file-schema/runtime/generatepublisherevidence-element) element.
+
]]>
@@ -115,11 +115,11 @@
An X.509 certificate representing the software publisher's identity.
Initializes a new instance of the class with the specified Authenticode X.509v3 certificate.
- The parameter is .
@@ -159,25 +159,16 @@
One of the values.
Initializes a new instance of the class with the specified .
- [!NOTE]
-> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
-
- In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
-
-
-## Examples
- The following example shows how to use the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/CPP/publisheridentitypermission.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/PublisherIdentityPermission/.ctor/publisheridentitypermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/VB/publisheridentitypermission.vb" id="Snippet7":::
-
+> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
+
+ In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
]]>The parameter is not a valid value of .
@@ -255,11 +246,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -301,10 +292,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -345,13 +336,13 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- only supports set operations (, , and ) when the current permission is equal to the specified permission.
-
+ only supports set operations (, , and ) when the current permission is equal to the specified permission.
+
]]>The parameter is not and is not of the same type as the current permission.
@@ -395,13 +386,13 @@
if the current permission is a subset of the specified permission; otherwise, .
- supports set operations (, , and ) only when the current permission is equal to the specified permission.
-
+ supports set operations (, , and ) only when the current permission is equal to the specified permission.
+
]]>The parameter is not and is not of the same type as the current permission.
@@ -480,19 +471,19 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- method is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
- The class only supports set operations (, , and ) when the current permission is equal to the specified permission.
-
+ method is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
+ The class only supports set operations (, , and ) when the current permission is equal to the specified permission.
+
]]>
- The parameter is not and is not of the same type as the current permission.
-
- -or-
-
+ The parameter is not and is not of the same type as the current permission.
+
+ -or-
+
The two permissions are not equal.
diff --git a/xml/System.Security.Permissions/ReflectionPermission.xml b/xml/System.Security.Permissions/ReflectionPermission.xml
index 21c0b1dcd94..f0f8198dc35 100644
--- a/xml/System.Security.Permissions/ReflectionPermission.xml
+++ b/xml/System.Security.Permissions/ReflectionPermission.xml
@@ -53,21 +53,21 @@
Controls access to non-public types and members through the APIs. Controls some features of the APIs.
- , code can use reflection to access only the public members of objects. Code with and the appropriate flags can access the `protected` and `private` members of objects.
-
+ Without , code can use reflection to access only the public members of objects. Code with and the appropriate flags can access the `protected` and `private` members of objects.
+
> [!CAUTION]
-> Because can provide access to non-public types and members, we recommend that you do not grant to Internet code, except with the flag. allows access to non-public members, with the restriction that the grant set of the non-public members must be equal to, or a subset of, the grant set of the code that accesses the non-public members.
-
- Certain features of reflection emit, such as emitting debug symbols, require with the flag.
-
- For more information, see the enumeration.
-
+> Because can provide access to non-public types and members, we recommend that you do not grant to Internet code, except with the flag. allows access to non-public members, with the restriction that the grant set of the non-public members must be equal to, or a subset of, the grant set of the code that accesses the non-public members.
+
+ Certain features of reflection emit, such as emitting debug symbols, require with the flag.
+
+ For more information, see the enumeration.
+
]]>
@@ -119,19 +119,11 @@
One of the values.
Initializes a new instance of the class with either fully restricted or unrestricted permission as specified.
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet7":::
-
+ The parameter is not a valid value of .
@@ -169,17 +161,7 @@
One of the values.
Initializes a new instance of the class with the specified access.
-
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet8":::
-
- ]]>
-
+ To be added.The parameter is not a valid value of .
@@ -217,22 +199,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet5":::
-
+
@@ -269,17 +240,7 @@
Gets or sets the type of reflection allowed for the current permission.The set flags for the current permission.
-
- property. This example is part of a larger example provided for the class.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet2":::
-
- ]]>
-
+ To be added.An attempt is made to set this property to an invalid value. See for the valid values.
@@ -318,25 +279,12 @@
The XML encoding to use to reconstruct the permission.
Reconstructs a permission with a specified state from an XML encoding.
-
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet6":::
-
- ]]>
-
+ To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -377,22 +325,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet4":::
-
+ The parameter is not and is not of the same type as the current permission.
@@ -436,22 +373,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet2":::
-
+ The parameter is not and is not of the same type as the current permission.
@@ -495,11 +421,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -537,20 +463,7 @@
Creates an XML encoding of the permission and its current state.An XML encoding of the permission, including any state information.
-
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet6":::
-
- ]]>
-
+ To be added.
@@ -590,22 +503,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet3":::
-
+ is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/ReflectionPermissionFlag.xml b/xml/System.Security.Permissions/ReflectionPermissionFlag.xml
index ff8d809c7b8..5dd3281fc9b 100644
--- a/xml/System.Security.Permissions/ReflectionPermissionFlag.xml
+++ b/xml/System.Security.Permissions/ReflectionPermissionFlag.xml
@@ -66,14 +66,6 @@
> [!IMPORTANT]
> `AllFlags` does not include the `RestrictedMemberAccess` flag. To get a mask that includes all flags in this enumeration, you must use the combination of `AllFlags` with `RestrictedMemberAccess`.
-## Examples
- The following example shows how to use the `ReflectionPermissionFlag` enumeration to initialize a new instance of the class that represents the right to perform restricted member access. This example is part of a larger example that is provided for the class.
-
- For an example that shows how to use the RestrictedMemberAccess flag with Internet code, see [Walkthrough: Emitting Code in Partial Trust Scenarios](/dotnet/framework/reflection-and-codedom/walkthrough-emitting-code-in-partial-trust-scenarios).
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ReflectionPermission/.ctor/reflectionpermission.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb" id="Snippet8":::
-
]]>
diff --git a/xml/System.Security.Permissions/RegistryPermission.xml b/xml/System.Security.Permissions/RegistryPermission.xml
index e2e4a245e10..9e228a662bb 100644
--- a/xml/System.Security.Permissions/RegistryPermission.xml
+++ b/xml/System.Security.Permissions/RegistryPermission.xml
@@ -53,21 +53,21 @@
Controls the ability to access registry variables. This class cannot be inherited.
- describes protected operations on registry variables. Registry variables should not be stored in memory locations where code without can access them. If the registry object is passed to an untrusted caller it can be misused.
-
- The allowed registry access types are defined by . If more than one type of access is desired, they can be combined using the bitwise OR operation as shown in the code sample that follows.
-
- Registry permission is defined in terms of canonical absolute paths; checks should always be made with canonical pathnames. Key access implies access to all values it contains and all variables under it.
-
+ describes protected operations on registry variables. Registry variables should not be stored in memory locations where code without can access them. If the registry object is passed to an untrusted caller it can be misused.
+
+ The allowed registry access types are defined by . If more than one type of access is desired, they can be combined using the bitwise OR operation as shown in the code sample that follows.
+
+ Registry permission is defined in terms of canonical absolute paths; checks should always be made with canonical pathnames. Key access implies access to all values it contains and all variables under it.
+
> [!NOTE]
-> In versions of .NET Framework before .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
-
+> In versions of .NET Framework before .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
+
]]>
@@ -117,19 +117,11 @@
One of the values.
Initializes a new instance of the class with either fully restricted or unrestricted permission as specified.
- constructor.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/RegistryPermission/.ctor/registrypermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb" id="Snippet7":::
-
+ The parameter is not a valid value of .
@@ -176,25 +168,17 @@
A list of registry variables (semicolon-separated) to which access is granted.
Initializes a new instance of the class with the specified access to the specified registry variables.
- values to be specified. This access applies to all listed registry variables. Use to define more complicated permissions.
-
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/RegistryPermission/.ctor/registrypermission.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb" id="Snippet10":::
-
+ values to be specified. This access applies to all listed registry variables. Use to define more complicated permissions.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
The parameter is not a valid string.
@@ -240,22 +224,22 @@
A list of registry variables (semicolon-separated) to which access is granted.
Initializes a new instance of the class with the specified access to the specified registry variables and the specified access rights to registry control information.
- values to be specified. This access applies to all listed registry variables. Use to define more complicated permissions.
-
- The `control` parameter specifies whether the access control list (ACL) for the registry keys specified by `pathList` can be changed, viewed, or cannot be accessed.
-
+ values to be specified. This access applies to all listed registry variables. Use to define more complicated permissions.
+
+ The `control` parameter specifies whether the access control list (ACL) for the registry keys specified by `pathList` can be changed, viewed, or cannot be accessed.
+
> [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the specified registry keys. The ability to change or view an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the specified registry keys. The ability to change or view an ACL is an important permission and should be granted with caution.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
The parameter is not a valid string.
@@ -268,11 +252,11 @@
Adds access for the specified registry variables to the existing state of the permission.
-
@@ -321,25 +305,17 @@
A list of registry variables (semicolon-separated).
Adds access for the specified registry variables to the existing state of the permission.
- method.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/RegistryPermission/.ctor/registrypermission.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb" id="Snippet9":::
-
+
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
The parameter is not a valid string.
@@ -395,22 +371,22 @@
A list of registry variables (separated by semicolons).
Adds access for the specified registry variables to the existing state of the permission, specifying registry permission access and access control actions.
- [!IMPORTANT]
-> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the specified registry keys. The ability to change or view an ACL is an important permission and should be granted with caution.
-
+> An access control list (ACL) describes individuals or groups who have, or do not have, rights to specific actions on the specified registry keys. The ability to change or view an ACL is an important permission and should be granted with caution.
+
]]>
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
The parameter is not a valid string.
@@ -448,11 +424,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -507,10 +483,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -557,29 +533,21 @@
Gets paths for all registry variables with the specified .A list of the registry variables (semicolon-separated) with the specified .
- [!NOTE]
-> The `access` parameter is limited to the values of , which represent single types of registry variable access. Those values are , , and . The values acceptable to `access` do not include and , which do not represent single types of registry variable access.
-
-
-
-## Examples
- The following code example shows the use of the method.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/RegistryPermission/.ctor/registrypermission.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb" id="Snippet9":::
-
+> The `access` parameter is limited to the values of , which represent single types of registry variable access. Those values are , , and . The values acceptable to `access` do not include and , which do not represent single types of registry variable access.
+
]]>
- is not a valid value of .
-
- -or-
-
+ is not a valid value of .
+
+ -or-
+
is , which represents more than one type of registry variable access, or , which does not represent any type of registry variable access.
@@ -626,11 +594,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- The parameter is not and is not of the same type as the current permission.
@@ -680,11 +648,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- The parameter is not and is not of the same type as the current permission.
@@ -728,11 +696,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -781,25 +749,17 @@
A list of registry variables (semicolon-separated).
Sets new access for the specified registry variable names to the existing state of the permission.
- method.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/RegistryPermission/.ctor/registrypermission.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb" id="Snippet9":::
-
+
- The parameter is not a valid value of .
-
- -or-
-
+ The parameter is not a valid value of .
+
+ -or-
+
The parameter is not a valid string.
@@ -888,11 +848,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
+ is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/ResourcePermissionBase.xml b/xml/System.Security.Permissions/ResourcePermissionBase.xml
index 58adf3e6db4..da556361921 100644
--- a/xml/System.Security.Permissions/ResourcePermissionBase.xml
+++ b/xml/System.Security.Permissions/ResourcePermissionBase.xml
@@ -48,22 +48,15 @@
Allows control of code access security permissions.
- [!NOTE]
> The class compares strings using ordinal sort rules and ignores the case of the strings being compared.
-
-## Examples
- The following example inherits from the class. 4 kinds of constructors are implemented. The example also provides an implementation of a class called `MailslotPermissionEntry`. The property is then privately set to the type of `MailslotPermissionEntry`. The property is set privately to "Name" and "Machine".
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ResourcePermissionBase/Overview/resourcepermissionbase.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb" id="Snippet1":::
-
+
]]>
@@ -179,23 +172,12 @@
The to add.
Adds a permission entry to the permission.
-
- method to add a permission access entry during class initialization. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ResourcePermissionBase/Overview/resourcepermissionbase.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb" id="Snippet2":::
-
- ]]>
-
+ To be added.The specified is .
- The number of elements in the property is not equal to the number of elements in the property.
-
- -or-
-
+ The number of elements in the property is not equal to the number of elements in the property.
+
+ -or-
+
The is already included in the permission.
@@ -231,11 +213,11 @@
Specifies the character to be used to represent the any wildcard character.
-
@@ -307,11 +289,11 @@
Creates and returns an identical copy of the current permission object.A copy of the current permission object.
-
@@ -351,10 +333,10 @@
The XML encoding to use to reconstruct the security object.
Reconstructs a security object with a specified state from an XML encoding.To be added.
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The version number of the parameter is not supported.The parameter is .
@@ -392,11 +374,11 @@
Returns an array of the objects added to this permission.An array of objects that were added to this permission.
- and to add and remove permission entries to this permission.
-
+ and to add and remove permission entries to this permission.
+
]]>
@@ -440,11 +422,11 @@
Creates and returns a permission object that is the intersection of the current permission object and a target permission object.A new permission object that represents the intersection of the current object and the specified target. This object is if the intersection is empty.
- The target permission object is not of the same type as the current permission object.
@@ -487,13 +469,13 @@
if the current permission object is a subset of the specified permission object; otherwise, .
-
@@ -535,11 +517,11 @@
if permission is unrestricted; otherwise, .
-
@@ -575,11 +557,11 @@
Specifies the character to be used to represent a local reference.
-
@@ -665,10 +647,10 @@
Removes a permission entry from the permission.To be added.The specified is .
- The number of elements in the property is not equal to the number of elements in the property.
-
- -or-
-
+ The number of elements in the property is not equal to the number of elements in the property.
+
+ -or-
+
The is not in the permission.
@@ -789,11 +771,11 @@
Creates a permission object that combines the current permission object and the target permission object.A new permission object that represents the union of the current permission object and the specified permission object.
- is a permission that represents all the operations represented by both the current permission object and the specified permission object. Any demand that passes either permission passes their union.
-
+ is a permission that represents all the operations represented by both the current permission object and the specified permission object. Any demand that passes either permission passes their union.
+
]]>The permission object is not of the same type as the current permission object.
diff --git a/xml/System.Security.Permissions/ResourcePermissionBaseEntry.xml b/xml/System.Security.Permissions/ResourcePermissionBaseEntry.xml
index 5ed3039812f..0b420116dcd 100644
--- a/xml/System.Security.Permissions/ResourcePermissionBaseEntry.xml
+++ b/xml/System.Security.Permissions/ResourcePermissionBaseEntry.xml
@@ -49,14 +49,7 @@
## Remarks
[!INCLUDE[cas-deprecated](~/includes/cas-deprecated.md)]
-
-## Examples
- The following example inherits from the class. 4 kinds of constructors are implemented. The example also provides an implementation of a class called `MailslotPermissionEntry`. The property is then privately set to the type of `MailslotPermissionEntry`. The property is set privately to "Name" and "Machine".
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ResourcePermissionBase/Overview/resourcepermissionbase.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/ResourcePermissionBase/VB/resourcepermissionbase.vb" id="Snippet1":::
-
+
]]>
@@ -98,11 +91,11 @@
Initializes a new instance of the class.
- property is set to zero.
-
+ property is set to zero.
+
]]>
@@ -222,11 +215,11 @@
Gets an array of strings that identify the resource you are protecting.An array of strings that identify the resource you are protecting.
- has two properties, and . The for returns + "\\\\" + . For example, "myMachine\\\myCategory".
-
+ has two properties, and . The for returns + "\\\\" + . For example, "myMachine\\\myCategory".
+
]]>
diff --git a/xml/System.Security.Permissions/SecurityAction.xml b/xml/System.Security.Permissions/SecurityAction.xml
index 7a53b0028b8..88a458c265a 100644
--- a/xml/System.Security.Permissions/SecurityAction.xml
+++ b/xml/System.Security.Permissions/SecurityAction.xml
@@ -86,42 +86,33 @@
Specifies the security actions that can be performed using declarative security.
- [!IMPORTANT]
-> In .NET Framework 4, runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests. These requests should not be used in code that is based on .NET Framework 4 or later. For more information about this and other changes, see [Security Changes](/dotnet/framework/security/security-changes).
+> In .NET Framework 4, runtime support has been removed for enforcing the Deny, RequestMinimum, RequestOptional, and RequestRefuse permission requests. These requests should not be used in code that is based on .NET Framework 4 or later. For more information about this and other changes, see [Security Changes](/dotnet/framework/security/security-changes).
+
+ You should not use `LinkDemand` in .NET Framework 4. Instead, use the to restrict usage to fully trusted applications, or use `Demand` to restrict partially trusted callers.
+
+| Declaration of security action | Time of action | Targets supported |
+|--------------------------------------------------|--------------------------|-------------------|
+| `LinkDemand` (do not use in .NET Framework 4+) | Just-in-time compilation | Class, method |
+| `InheritanceDemand` | Load time | Class, method |
+| `Demand` | Run time | Class, method |
+| `Assert` | Run time | Class, method |
+| `Deny` (obsolete in .NET Framework 4) | Run time | Class, method |
+| `PermitOnly` | Run time | Class, method |
+| `RequestMinimum` (obsolete in .NET Framework 4) | Grant time | Assembly |
+| `RequestOptional` (obsolete in .NET Framework 4) | Grant time | Assembly |
+| `RequestRefuse` (obsolete in .NET Framework 4) | Grant time | Assembly |
+
+ For additional information about attribute targets, see .
- You should not use `LinkDemand` in .NET Framework 4. Instead, use the to restrict usage to fully trusted applications, or use `Demand` to restrict partially trusted callers.
-
-|Declaration of security action|Time of action|Targets supported|
-|------------------------------------|--------------------|-----------------------|
-|`LinkDemand` (do not use in the .NET Framework 4)|Just-in-time compilation|Class, method|
-|`InheritanceDemand`|Load time|Class, method|
-|`Demand`|Run time|Class, method|
-|`Assert`|Run time|Class, method|
-|`Deny` (obsolete in the .NET Framework 4)|Run time|Class, method|
-|`PermitOnly`|Run time|Class, method|
-|`RequestMinimum` (obsolete in the .NET Framework 4)|Grant time|Assembly|
-|`RequestOptional` (obsolete in the .NET Framework 4)|Grant time|Assembly|
-|`RequestRefuse` (obsolete in the .NET Framework 4)|Grant time|Assembly|
-
- For additional information about attribute targets, see .
-
-
-
-## Examples
- This example shows how to notify the CLR that code in called methods has only , and also demonstrates how to write and read from isolated storage.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/IsolatedStorageContainment/Overview/IsolatedStoragePermissionAttribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/VB/program.vb" id="Snippet1":::
-
]]>
diff --git a/xml/System.Security.Permissions/SecurityAttribute.xml b/xml/System.Security.Permissions/SecurityAttribute.xml
index e3be99ebede..ff3c5cb5f93 100644
--- a/xml/System.Security.Permissions/SecurityAttribute.xml
+++ b/xml/System.Security.Permissions/SecurityAttribute.xml
@@ -158,11 +158,11 @@
One of the values.
Initializes a new instance of with the specified .
- property.
-
+ property.
+
]]>
@@ -216,20 +216,11 @@
Gets or sets a security action.One of the values.
- value. This value will be used to set the property.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/FileIOPermissionAttribute/Overview/source.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/VB/source.vb" id="Snippet1":::
-
+
@@ -285,11 +276,11 @@
When overridden in a derived class, creates a permission object that can then be serialized into binary form and persistently stored along with the in an assembly's metadata.A serializable permission object.
-
@@ -344,11 +335,11 @@
if full permission to the protected resource is declared; otherwise, .
-
diff --git a/xml/System.Security.Permissions/SecurityPermission.xml b/xml/System.Security.Permissions/SecurityPermission.xml
index c06ad76ea99..3cd03ec3664 100644
--- a/xml/System.Security.Permissions/SecurityPermission.xml
+++ b/xml/System.Security.Permissions/SecurityPermission.xml
@@ -53,14 +53,14 @@
Describes a set of security permissions applied to code. This class cannot be inherited.
- enumeration. The values for this enumeration can be found in its documentation.
-
+ This permission uses the enumeration. The values for this enumeration can be found in its documentation.
+
]]>
@@ -110,11 +110,11 @@
One of the values.
Initializes a new instance of the class with either restricted or unrestricted permission as specified.
- The parameter is not a valid value of .
@@ -152,18 +152,7 @@
The initial state of the permission, represented by a bitwise OR combination of any permission bits defined by .
Initializes a new instance of the class with the specified initial set state of the flags.
-
- constructor to create instances of the class that are used to demand security permissions. For the complete code example, see the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp" id="Snippet18":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/SecurityPermission/.ctor/securitypermissionattribute.cs" id="Snippet18":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb" id="Snippet18":::
-
- ]]>
-
+ To be added.The parameter is not a valid value of .
@@ -201,11 +190,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -243,11 +232,11 @@
Gets or sets the security permission flags.The state of the current permission, represented by a bitwise OR combination of any permission bits defined by .
- An attempt is made to set this property to an invalid value. See for the valid values.
@@ -290,10 +279,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not supported.
@@ -334,11 +323,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission object that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- The parameter is not and is not of the same type as the current permission.
@@ -382,11 +371,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- The parameter is not and is not of the same type as the current permission.
@@ -430,11 +419,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -512,11 +501,11 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
+ is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
+
]]>The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/SecurityPermissionFlag.xml b/xml/System.Security.Permissions/SecurityPermissionFlag.xml
index a9fdc90a917..8d56974f32f 100644
--- a/xml/System.Security.Permissions/SecurityPermissionFlag.xml
+++ b/xml/System.Security.Permissions/SecurityPermissionFlag.xml
@@ -90,25 +90,17 @@
Specifies access flags for the security permission object.
- .
-
+
+ This enumeration is used by .
+
> [!CAUTION]
> Many of these flags are powerful and should only be granted to highly trusted code.
-
-## Examples
-The following example shows the use of the enumeration to deny and demand security permissions:
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/SecurityPermission/.ctor/securitypermissionattribute.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb" id="Snippet1":::
-
]]>
diff --git a/xml/System.Security.Permissions/StorePermissionFlags.xml b/xml/System.Security.Permissions/StorePermissionFlags.xml
index 2bf56f41e26..41458ac36c7 100644
--- a/xml/System.Security.Permissions/StorePermissionFlags.xml
+++ b/xml/System.Security.Permissions/StorePermissionFlags.xml
@@ -46,21 +46,14 @@
Specifies the permitted access to X.509 certificate stores.
- enumeration.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/CPP/storepermission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StorePermissionFlags/Overview/storepermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/VB/program.vb" id="Snippet2":::
-
+Many of these access permissions pose potential security and privacy threats. Great care should be taken in granting access to stores. A brief description of the type of threat exposed by an access can be found in the summary for the individual enumeration member.
+
]]>
diff --git a/xml/System.Security.Permissions/StrongNameIdentityPermission.xml b/xml/System.Security.Permissions/StrongNameIdentityPermission.xml
index c2b05faf7e3..3417368ff70 100644
--- a/xml/System.Security.Permissions/StrongNameIdentityPermission.xml
+++ b/xml/System.Security.Permissions/StrongNameIdentityPermission.xml
@@ -137,15 +137,6 @@
Use this constructor with a permission state value of to create an identity permission that matches no strong names. If you subsequently set the and properties, a specific strong name identity can be represented by the permission.
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet7":::
-
]]>
The parameter is not a valid value of .
@@ -195,15 +186,6 @@
For more information on names and version numbers of assemblies, see [Strong-named assemblies](/dotnet/standard/assembly/strong-named).
-
-
-## Examples
- The following code example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet8":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet8":::
-
]]>
The parameter is .
@@ -249,18 +231,6 @@
## Remarks
A copy of a permission represents the same access to resources as the original permission.
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class. The best use for this example is to build and execute the entire example, and view its output.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet5":::
-
]]>
@@ -306,18 +276,6 @@
## Remarks
This method is not used by application code.
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class. The best use for this example is to build and execute the entire example, and view its output.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet6":::
-
]]>
The parameter is .
@@ -372,18 +330,6 @@
The intersection of two identical strong name identity permissions is the same permission. The intersection of two different (not wildcard) expressions is an empty permission. The intersection of a wildcard expression and a matching strong name is the strong name. The intersection of two wildcard expressions that match is the longer, more specific of the two expressions.
-
-
-## Examples
- The following code example shows the results of the use of the method, not how to use the method. This example is part of a larger example provided for the class. The best use for this example is to build and execute the entire example, and view its output.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet4":::
-
]]>
The parameter is not and is not of the same type as the current permission.
@@ -432,18 +378,6 @@
## Remarks
The current permission is a subset of the specified permission if the current permission specifies a set of operations that is wholly contained by the specified permission. For example, the other properties being equal, an identity with the property containing the wildcard expression MyCompany.MyDepartment.* is identified as a subset of an identity with the property MyCompany.MyDepartment.MyFile.
-
-
-## Examples
- The following code example shows the results of the use of the method, not how to use the method. This example is part of a larger example provided for the class. The best use for this example is to build and execute the entire example, and view its output.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet2":::
-
]]>
The parameter is not and is not of the same type as the current permission.
@@ -569,18 +503,6 @@
## Remarks
This method is not typically used by application code.
-
-
-## Examples
- The following code example shows the behavior of the method.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet6":::
-
]]>
@@ -629,18 +551,6 @@
The union of a permission and `null` is the permission that is not `null`. The union of a permission and a subset of that permission is the permission that contains the other. Any other combination results in an exception being thrown.
-
-
-## Examples
- The following code example shows the results of the use of the method, not how to use the method. This example is part of a larger example provided for the class. The best use for this example is to build and execute the entire example, and view its output.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/StrongNameIdentityPermission/.ctor/strongnameidentity.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb" id="Snippet3":::
-
]]>
The parameter is not and is not of the same type as the current permission.
diff --git a/xml/System.Security.Permissions/UIPermission.xml b/xml/System.Security.Permissions/UIPermission.xml
index 9cf467dbea1..90f082f2170 100644
--- a/xml/System.Security.Permissions/UIPermission.xml
+++ b/xml/System.Security.Permissions/UIPermission.xml
@@ -53,18 +53,18 @@
Controls the permissions related to user interfaces and the Clipboard. This class cannot be inherited.
- , only , or no window drawing or user input event access allowed. and are restricted in title and size to prevent possible spoofing by potentially harmful code.
-
- The permission to use the Clipboard can be one of the following: unrestricted, write-only, or no Clipboard access allowed. The paste limitation prevents potentially harmful applications from taking data from the Clipboard without the user's consent, while still allowing the cut, copy, and paste operations when initiated by the user through keyboard commands.
-
+ Drawing and user input events in windows are user interfaces.
+
+ The permission to use windows can be one of the following: unrestricted, limited to , only , or no window drawing or user input event access allowed. and are restricted in title and size to prevent possible spoofing by potentially harmful code.
+
+ The permission to use the Clipboard can be one of the following: unrestricted, write-only, or no Clipboard access allowed. The paste limitation prevents potentially harmful applications from taking data from the Clipboard without the user's consent, while still allowing the cut, copy, and paste operations when initiated by the user through keyboard commands.
+
]]>
@@ -115,20 +115,11 @@
One of the enumeration values.
Initializes a new instance of the class with either fully restricted or unrestricted access, as specified.
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet7":::
-
+ The parameter is not a valid .
@@ -167,20 +158,11 @@
One of the enumeration values.
Initializes a new instance of the class with the permissions for the Clipboard, and no access to windows.
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet9":::
-
+ The parameter is not a valid value.
@@ -219,20 +201,11 @@
One of the enumeration values.
Initializes a new instance of the class with the permissions for windows, and no access to the Clipboard.
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet8":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet8":::
-
+ The parameter is not a valid value.
@@ -272,22 +245,11 @@
One of the enumeration values.
One of the enumeration values.
Initializes a new instance of the class with the specified permissions for windows and the Clipboard.
-
- constructor. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet10":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet10":::
-
- ]]>
-
- The parameter is not a valid value.
-
- -or-
-
+ To be added.
+ The parameter is not a valid value.
+
+ -or-
+
The parameter is not a valid value.
@@ -360,23 +322,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet5":::
-
+
@@ -416,26 +366,12 @@
The XML encoding used to reconstruct the permission.
Reconstructs a permission with a specified state from an XML encoding.
-
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet6":::
-
- ]]>
-
+ To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -476,23 +412,11 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- and from those in the current permission and the specified permission.
-
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet4":::
-
+ and from those in the current permission and the specified permission.
+
]]>The parameter is not and is not of the same type as the current permission.
@@ -536,23 +460,11 @@
if the current permission is a subset of the specified permission; otherwise, .
- to return `true`, both the and values of the current permission must be equal to or less permissive than the values of the specified permission.
-
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet2":::
-
+ to return `true`, both the and values of the current permission must be equal to or less permissive than the values of the specified permission.
+
]]>The parameter is not and is not of the same type as the current permission.
@@ -596,11 +508,11 @@
if the current permission is unrestricted; otherwise, .
-
@@ -638,21 +550,7 @@
Creates an XML encoding of the permission and its current state.An XML encoding of the permission, including any state information.
-
- method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet6":::
-
- ]]>
-
+ To be added.
@@ -692,23 +590,11 @@
Creates a permission that is the union of the permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- is a permission that represents all the operations represented by the current permission as well as all the operations represented by the specified permission. Specifically, it represents the most permissive values of and from those in the current permission and the specified permission.
-
-
-
-## Examples
- The following code example shows the behavior of the method. This example is part of a larger example provided for the class.
-
-> [!NOTE]
-> The code example is intended to show the behavior of the method, not to demonstrate its use. In general, the methods of permission classes are used by the security infrastructure; they are not typically used in applications.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet3":::
-
+ is a permission that represents all the operations represented by the current permission as well as all the operations represented by the specified permission. Specifically, it represents the most permissive values of and from those in the current permission and the specified permission.
+
]]>The parameter is not and is not of the same type as the current permission.
@@ -746,18 +632,7 @@
Gets or sets the window access represented by the permission.One of the values.
-
- property. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UIPermission/.ctor/uipermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb" id="Snippet2":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Permissions/UrlIdentityPermission.xml b/xml/System.Security.Permissions/UrlIdentityPermission.xml
index 4967b7d9468..8e4277a871a 100644
--- a/xml/System.Security.Permissions/UrlIdentityPermission.xml
+++ b/xml/System.Security.Permissions/UrlIdentityPermission.xml
@@ -49,27 +49,27 @@
Defines the identity permission for the URL from which the code originates. This class cannot be inherited.
- [!IMPORTANT]
-> Starting with the .NET Framework 4, identity permissions are not used.
->
-> In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
+> Starting with the .NET Framework 4, identity permissions are not used.
+>
+> In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
> [!NOTE]
-> In versions of the .NET Framework before the .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
-
+> In versions of the .NET Framework before the .NET Framework 4, you could use the method to prevent inadvertent access to system resources by trusted code. is now obsolete, and access to resources is now determined solely by the granted permission set for an assembly. To limit access to files, you must run partially trusted code in a sandbox and assign it permissions only to resources that the code is allowed to access. For information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
+
> [!NOTE]
-> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface.
-
+> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface.
+
]]>
@@ -120,25 +120,16 @@
One of the values.
Initializes a new instance of the class with the specified .
- [!NOTE]
-> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
-
- In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
-
-
-## Examples
- The following example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UrlIdentityPermission/.ctor/urlidentity.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb" id="Snippet7":::
-
+> In the .NET Framework versions 1.0 and 1.1, identity permissions cannot have an permission state value. Starting with the .NET Framework version 2.0, identity permissions can have any permission state value. This means that in 2.0 and later versions, identity permissions have the same behavior as permissions that implement the interface. That is, a demand for an identity always succeeds, regardless of the identity of the assembly, if the assembly has been granted full trust.
+
+ In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
+
]]>The parameter is not a valid value of .
@@ -177,25 +168,16 @@
A URL or wildcard expression.
Initializes a new instance of the class to represent the URL identity described by .
- [!NOTE]
-> Starting with the .NET Framework version 2.0, for performance reasons, an invalid URL does not cause an argument exception at the time the new class instance is created. The argument exception will occur when one of the set operations (Union, Intersect, or IsSubsetOf) is executed. A demand on the permission causes to be called by the security infrastructure. The demand will fail because of the argument exception, resulting in a being thrown. In this case, the original exception will not be seen.
-
-
-
-## Examples
- The following example shows the use of the constructor.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp" id="Snippet8":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/UrlIdentityPermission/.ctor/urlidentity.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb" id="Snippet8":::
-
+> Starting with the .NET Framework version 2.0, for performance reasons, an invalid URL does not cause an argument exception at the time the new class instance is created. The argument exception will occur when one of the set operations (Union, Intersect, or IsSubsetOf) is executed. A demand on the permission causes to be called by the security infrastructure. The demand will fail because of the argument exception, resulting in a being thrown. In this case, the original exception will not be seen.
+
]]>The parameter is .
@@ -237,11 +219,11 @@
Creates and returns an identical copy of the current permission.A copy of the current permission.
-
@@ -283,10 +265,10 @@
Reconstructs a permission with a specified state from an XML encoding.To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not valid.
@@ -327,19 +309,19 @@
Creates and returns a permission that is the intersection of the current permission and the specified permission.A new permission that represents the intersection of the current permission and the specified permission. This new permission is if the intersection is empty.
- supports set operations (, , and ) only when the current permission is equal to the specified permission object or when one of the permissions uses the wildcard operator ("\*").
-
+ supports set operations (, , and ) only when the current permission is equal to the specified permission object or when one of the permissions uses the wildcard operator ("\*").
+
]]>
- The parameter is not and is not of the same type as the current permission.
-
- -or-
-
+ The parameter is not and is not of the same type as the current permission.
+
+ -or-
+
The Url property is not a valid URL.
@@ -381,19 +363,19 @@
if the current permission is a subset of the specified permission; otherwise, .
- supports set operations (, , and ) only when the current permission is equal to the specified permission or when one of the permissions uses the wildcard operator ("\*").
-
+ supports set operations (, , and ) only when the current permission is equal to the specified permission or when one of the permissions uses the wildcard operator ("\*").
+
]]>
- The parameter is not and is not of the same type as the current permission.
-
- -or-
-
+ The parameter is not and is not of the same type as the current permission.
+
+ -or-
+
The Url property is not a valid URL.
@@ -470,23 +452,23 @@
Creates a permission that is the union of the current permission and the specified permission.A new permission that represents the union of the current permission and the specified permission.
- method is a permission that represents access to the URL as represented by the current permission, as well as access to the URL as represented by the specified permission.
-
- The class supports set operations , , and ) only when the current permission is equal to the specified permission, or when one of the permissions uses the wildcard operator ("\*") and one is a subset of the other.
-
+ method is a permission that represents access to the URL as represented by the current permission, as well as access to the URL as represented by the specified permission.
+
+ The class supports set operations , , and ) only when the current permission is equal to the specified permission, or when one of the permissions uses the wildcard operator ("\*") and one is a subset of the other.
+
]]>
- The parameter is not and is not of the same type as the current permission.
-
- -or-
-
- The property is not a valid URL.
-
- -or-
-
+ The parameter is not and is not of the same type as the current permission.
+
+ -or-
+
+ The property is not a valid URL.
+
+ -or-
+
The two permissions are not equal and one is not a subset of the other.The operation is ambiguous because the permission represents multiple identities.
@@ -524,13 +506,13 @@
Gets or sets a URL representing the identity of Internet code.A URL representing the identity of Internet code.
- The URL cannot be retrieved because it has an ambiguous identity.
diff --git a/xml/System.Security.Permissions/WebBrowserPermission.xml b/xml/System.Security.Permissions/WebBrowserPermission.xml
index 51e8b273f75..5347fe39dff 100644
--- a/xml/System.Security.Permissions/WebBrowserPermission.xml
+++ b/xml/System.Security.Permissions/WebBrowserPermission.xml
@@ -145,14 +145,6 @@ This class is not typically used in XAML.
## Remarks
If `state` is set to , the value of the property is set to . If `state` is set to , the value of the property is set to .
-
-
-## Examples
- The following code example shows how to create a with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermission1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermission1":::
-
]]>
@@ -187,17 +179,7 @@ This class is not typically used in XAML.
An enumerated value of .
Initializes a new instance of the class by specifying the Web browser permission level.
-
- with a value.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermission2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermission2":::
-
- ]]>
-
+ To be added.
@@ -413,12 +395,6 @@ An unrestricted permission represents access to any and all resources protected
Members of this class are either not typically used in XAML, or cannot be used in XAML.
-## Examples
- The following code example shows how to use the method.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermission5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermission5":::
-
]]>
@@ -459,19 +435,7 @@ Members of this class are either not typically used in XAML, or cannot be used i
Gets or sets the current value of the Web browser permission level.The current value of the Web browser permission level.
-
- value for the .
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermission6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermission6":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Permissions/WebBrowserPermissionAttribute.xml b/xml/System.Security.Permissions/WebBrowserPermissionAttribute.xml
index 271bc48f8d2..3dcbb1da564 100644
--- a/xml/System.Security.Permissions/WebBrowserPermissionAttribute.xml
+++ b/xml/System.Security.Permissions/WebBrowserPermissionAttribute.xml
@@ -58,12 +58,6 @@ The security information declared by a security attribute is stored in the metad
This class is not typically used in XAML.
-## Examples
-
-The following example shows how to demand that the calling code has unrestricted permission to create a Web browser control.
-
-:::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermissionattribute3":::
-:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermissionattribute3":::
]]>
Extending Metadata Using Attributes
@@ -106,14 +100,6 @@ The following example shows how to demand that the calling code has unrestricted
One of the values.
Initializes a new instance of the class with the specified .Members of this class are either not typically used in XAML, or cannot be used in XAML.
-
- .
-
-:::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermissionattribute4":::
-:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermissionattribute4":::
- ]]>
-
@@ -198,19 +184,7 @@ Members of this class are either not typically used in XAML, or cannot be used i
Gets or sets the current Web browser permission level for the .The state of the current Web browser permission level. The default is .
-
-
-
+ To be added.
diff --git a/xml/System.Security.Permissions/WebBrowserPermissionLevel.xml b/xml/System.Security.Permissions/WebBrowserPermissionLevel.xml
index 6292194dd82..29339c55b5d 100644
--- a/xml/System.Security.Permissions/WebBrowserPermissionLevel.xml
+++ b/xml/System.Security.Permissions/WebBrowserPermissionLevel.xml
@@ -55,19 +55,9 @@
The Safe permission level restricts the following Web browser operations.
- A pop-up window cannot be created over the Web browser control.
-
- The Web browser control can only be navigated to its site of origin.
-
- The security settings of the Web browser control are reduced.
-
-
-## Examples
- The following example shows how to demand that the calling code has unrestricted permission to create a Web browser control.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/WebBrowserPermission/.ctor/Window1.xaml.cs" id="Snippetwebbrowserpermissionattribute3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Wpf/WebBrowserPermissionsSnippets/visualbasic/window1.xaml.vb" id="Snippetwebbrowserpermissionattribute3":::
-
]]>
diff --git a/xml/System.Security.Permissions/ZoneIdentityPermission.xml b/xml/System.Security.Permissions/ZoneIdentityPermission.xml
index 30eda55bdc1..2e6f4649b3a 100644
--- a/xml/System.Security.Permissions/ZoneIdentityPermission.xml
+++ b/xml/System.Security.Permissions/ZoneIdentityPermission.xml
@@ -130,14 +130,6 @@
In the .NET Framework versions 1.0 and 1.1, demands on the identity permissions are effective, even when the calling assembly is fully trusted. That is, although the calling assembly has full trust, a demand for an identity permission fails if the assembly does not meet the demanded criteria. Starting with the .NET Framework version 2.0, demands for identity permissions are ineffective if the calling assembly has full trust. This assures consistency for all permissions, eliminating the treatment of identity permissions as a special case.
-
-
-## Examples
- The following example shows the use of the constructor.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ZoneIdentityPermission/.ctor/zoneidentity.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb" id="Snippet7":::
-
]]>
The parameter is not a valid value of .
@@ -175,17 +167,7 @@
The zone identifier.
Initializes a new instance of the class to represent the specified zone identity.
-
- constructor.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security.Permissions/ZoneIdentityPermission/.ctor/zoneidentity.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb" id="Snippet8":::
-
- ]]>
-
+ To be added.
diff --git a/xml/System.Security.Policy/FileCodeGroup.xml b/xml/System.Security.Policy/FileCodeGroup.xml
index ba484d59517..1ab56945df3 100644
--- a/xml/System.Security.Policy/FileCodeGroup.xml
+++ b/xml/System.Security.Policy/FileCodeGroup.xml
@@ -49,27 +49,18 @@
Grants permission to manipulate files located in the code assemblies to code assemblies that match the membership condition. This class cannot be inherited.
- has the same child matching semantics as . However, returns a permission set containing a dynamically-calculated that grants file access to the directory from which the code is run; only returns a static permission set. The type of file access granted is passed as a parameter to the constructor.
-
- This code group only matches assemblies run over a file protocol, that is, assemblies that have URLs that point to a file or UNC path.
-
-
-
-## Examples
- The following example shows the use of members of the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet1":::
-
+ Code groups are the building blocks of code access security policy. Each policy level consists of a root code group that can have child code groups. Each child code group can have their own child code groups; this behavior extends to any number of levels, forming a tree. Each code group has a membership condition that determines if a given assembly belongs to it based on the evidence for that assembly. Only code groups whose membership conditions match a given assembly and their child code groups apply policy.
+
+ has the same child matching semantics as . However, returns a permission set containing a dynamically-calculated that grants file access to the directory from which the code is run; only returns a static permission set. The type of file access granted is passed as a parameter to the constructor.
+
+ This code group only matches assemblies run over a file protocol, that is, assemblies that have URLs that point to a file or UNC path.
+
]]>
@@ -109,29 +100,20 @@
One of the values. This value is used to construct the that is granted.
Initializes a new instance of the class.
- method.
-
- returns a permission set containing a dynamically-calculated that grants file access to the directory from which the code is run. The type of access granted is determined by the `access` parameter.
-
-
-
-## Examples
- The following code shows the use of the constructor. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet2":::
-
+ method.
+
+ returns a permission set containing a dynamically-calculated that grants file access to the directory from which the code is run. The type of access granted is determined by the `access` parameter.
+
]]>The parameter is .
- The type of the parameter is not valid.
-
- -or-
-
+ The type of the parameter is not valid.
+
+ -or-
+
The type of the parameter is not valid.
@@ -174,20 +156,11 @@
Gets a string representation of the attributes of the policy statement for the code group.Always .
- does not use , so this property is always `null`.
-
-
-
-## Examples
- The following code shows the use of the property to get the attributes for the code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet5":::
-
+ does not use , so this property is always `null`.
+
]]>
@@ -232,20 +205,11 @@
Makes a deep copy of the current code group.An equivalent copy of the current code group, including its membership conditions and child code groups.
- method to make a deep copy of the code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet18":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet18":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet18":::
-
+
@@ -333,18 +297,7 @@
Determines whether the specified code group is equivalent to the current code group. if the specified code group is equivalent to the current code group; otherwise, .
-
- method to determine if two code groups are equal. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet20":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet20":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet20":::
-
- ]]>
-
+ To be added.
@@ -386,18 +339,7 @@
Gets the hash code of the current code group.The hash code of the current code group.
-
- method to get the hash code of the current code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet14":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet14":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet14":::
-
- ]]>
-
+ To be added.
@@ -432,18 +374,7 @@
Gets the merge logic.The string "Union".
-
- property to get the merge logic for this code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet15":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet15":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet15":::
-
- ]]>
-
+ To be added.
@@ -524,18 +455,7 @@
Gets the name of the named permission set for the code group.The concatenation of the string "Same directory FileIO - " and the access type.
-
- property to get the name of the named permission set for the code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet13":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet13":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet13":::
-
- ]]>
-
+ To be added.
@@ -581,31 +501,22 @@
Resolves policy for the code group and its descendants for a set of evidence.A policy statement consisting of the permissions granted by the code group with optional attributes, or if the code group does not apply (the membership condition does not match the specified evidence).
- on the policy levels to determine which permissions to grant to loaded code from the resulting policy statements and the code request on the assembly.
-
- uses union semantics and forms a permission set based on the specified by `evidence`.
-
-
-
-## Examples
- The following code shows the use of the method to resolve policy for the code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet19":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet19":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet19":::
-
+ on the policy levels to determine which permissions to grant to loaded code from the resulting policy statements and the code request on the assembly.
+
+ uses union semantics and forms a permission set based on the specified by `evidence`.
+
]]>The parameter is .
- The current policy is .
-
- -or-
-
+ The current policy is .
+
+ -or-
+
More than one code group (including the parent code group and all child code groups) is marked .
@@ -652,22 +563,13 @@
Resolves matching code groups.A that is the root of the tree of matching code groups.
- uses union semantics and forms a permission set based on the specified by `evidence`.
-
-
-
-## Examples
- The following code shows the use of the method to resolve matching code groups. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FileCodeGroup/Overview/members.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb" id="Snippet9":::
-
+ uses union semantics and forms a permission set based on the specified by `evidence`.
+
]]>The parameter is .
diff --git a/xml/System.Security.Policy/FirstMatchCodeGroup.xml b/xml/System.Security.Policy/FirstMatchCodeGroup.xml
index aa9bf9fb221..78d9354cad3 100644
--- a/xml/System.Security.Policy/FirstMatchCodeGroup.xml
+++ b/xml/System.Security.Policy/FirstMatchCodeGroup.xml
@@ -53,27 +53,18 @@
Allows security policy to be defined by the union of the policy statement of a code group and that of the first child code group that matches. This class cannot be inherited.
- only applies when its membership condition matches evidence for an assembly. If there is a match, it tests the membership condition of each child in order, stopping when the first match occurs. The result of is the union of the policy statement of the root code group and the policy statement of the first child group of that code group that matches.
-
- is intended for programmatic use by application domain hosts to set domain policy.
-
-
-
-## Examples
- The following example shows the use of members of the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet1":::
-
+ Code groups are the building blocks of code access security policy. Each policy level consists of a root code group that can have child code groups. Each child code group can have their own child code groups; this behavior extends to any number of levels, forming a tree. Each code group has a membership condition that determines if a given assembly belongs to it based on the evidence for that assembly. Only code groups whose membership conditions match a given assembly and their child code groups apply policy.
+
+ Like any code group, only applies when its membership condition matches evidence for an assembly. If there is a match, it tests the membership condition of each child in order, stopping when the first match occurs. The result of is the union of the policy statement of the root code group and the policy statement of the first child group of that code group that matches.
+
+ is intended for programmatic use by application domain hosts to set domain policy.
+
]]>
@@ -113,26 +104,17 @@
The policy statement for the code group in the form of a permission set and attributes to grant code that matches the membership condition.
Initializes a new instance of the class.
- method.
-
-
-
-## Examples
- The following code shows the use of the constructor. This code example is part of a larger example provided for class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet2":::
-
+ method.
+
]]>
- The type of the parameter is not valid.
-
- -or-
-
+ The type of the parameter is not valid.
+
+ -or-
+
The type of the parameter is not valid.
@@ -176,20 +158,11 @@
Makes a deep copy of the code group.An equivalent copy of the code group, including its membership conditions and child code groups.
- method to make a deep copy of the code group. This code example is part of a larger example provided for class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet18":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet18":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet18":::
-
+
@@ -226,18 +199,7 @@
Gets the merge logic.The string "First Match".
-
- property to get the merge logic for this code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet15":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet15":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet15":::
-
- ]]>
-
+ To be added.
@@ -283,28 +245,19 @@
Resolves policy for the code group and its descendants for a set of evidence.A policy statement consisting of the permissions granted by the code group with optional attributes, or if the code group does not apply (the membership condition does not match the specified evidence).
- methods of these child groups work.
-
- The .NET Framework security system uses on the policy levels to determine which permissions to grant to loaded code from the resulting policy statements and the code request on the assembly.
-
- This operation of this method is as follows:
-
- If the membership condition does not match the specified evidence, return `null`; otherwise, set the permission set to be returned (P) equal to the code group's policy statement and continue. For each child code group, resolve the code group with the same evidence; if the result is not `null`, return that policy statement. If no child code group matched, return P (the parent's policy statement).
-
-
-
-## Examples
- The following code shows the use of the method to resolve policy for the code group. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet19":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet19":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet19":::
-
+ methods of these child groups work.
+
+ The .NET Framework security system uses on the policy levels to determine which permissions to grant to loaded code from the resulting policy statements and the code request on the assembly.
+
+ This operation of this method is as follows:
+
+ If the membership condition does not match the specified evidence, return `null`; otherwise, set the permission set to be returned (P) equal to the code group's policy statement and continue. For each child code group, resolve the code group with the same evidence; if the result is not `null`, return that policy statement. If no child code group matched, return P (the parent's policy statement).
+
]]>The parameter is .
@@ -354,22 +307,13 @@
Resolves matching code groups.A that is the root of the tree of matching code groups.
- methods of these child groups work.
-
-
-
-## Examples
- The following code shows the use of the method to resolve matching code groups. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/FirstMatchCodeGroup/Overview/members.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb" id="Snippet9":::
-
+ methods of these child groups work.
+
]]>The parameter is .
diff --git a/xml/System.Security.Policy/GacInstalled.xml b/xml/System.Security.Policy/GacInstalled.xml
index cdb13f625c2..2f670329d83 100644
--- a/xml/System.Security.Policy/GacInstalled.xml
+++ b/xml/System.Security.Policy/GacInstalled.xml
@@ -58,23 +58,14 @@
Confirms that a code assembly originates in the global assembly cache (GAC) as evidence for policy evaluation. This class cannot be inherited.
- evidence produces a in the grant set. If there is a for , the that corresponds to the evidence is compared with the demanded permission.
-
-
-
-## Examples
- The following code example shows the use of the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet1":::
-
+ The presence of evidence produces a in the grant set. If there is a for , the that corresponds to the evidence is compared with the demanded permission.
+
]]>
@@ -107,20 +98,11 @@
Initializes a new instance of the class.
- object has no properties.
-
-
-
-## Examples
- The following code example shows the use of the constructor. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet2":::
-
+ object has no properties.
+
]]>
@@ -182,18 +164,7 @@
Creates an equivalent copy of the current object.An equivalent copy of .
-
- method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet4":::
-
- ]]>
-
+ To be added.
@@ -235,20 +206,11 @@
Creates a new identity permission that corresponds to the current object.A new identity permission that corresponds to the current object.
- can be used to determine whether the calling code is in the global assembly cache.
-
-
-
-## Examples
- The following code example shows the use of the method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet3":::
-
+ can be used to determine whether the calling code is in the global assembly cache.
+
]]>
@@ -290,20 +252,11 @@
if is a object; otherwise, .
- objects have no properties to distinguish one from another, so all objects are equal.
-
-
-
-## Examples
- The following code example shows the use of the method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.GacMembershipCondition/CPP/gacmembershipcondition.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Equals/gacmembershipcondition.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.GacMembershipCondition/VB/gacmembershipcondition.vb" id="Snippet5":::
-
+ objects have no properties to distinguish one from another, so all objects are equal.
+
]]>
@@ -341,20 +294,11 @@
Returns a hash code for the current object.A hash code for the current object.
- method returns 0 (zero) because objects have no properties to distinguish one from another.
-
-
-
-## Examples
- The following code example shows the use of the method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet5":::
-
+ method returns 0 (zero) because objects have no properties to distinguish one from another.
+
]]>
@@ -392,20 +336,11 @@
Returns a string representation of the current object.A string representation of the current object.
- method. This example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security.Policy/GacInstalled/Overview/gac.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb" id="Snippet6":::
-
+
diff --git a/xml/System.Security/CodeAccessPermission.xml b/xml/System.Security/CodeAccessPermission.xml
index 374da30f0ee..ec8d3e9a853 100644
--- a/xml/System.Security/CodeAccessPermission.xml
+++ b/xml/System.Security/CodeAccessPermission.xml
@@ -71,15 +71,6 @@
Inheritors of the class must be granted full trust to function correctly as permissions extending the security infrastructure. To determine that the inheritors are fully trusted, issues an for = `true` and = `true`.
-
-
-## Examples
- The following code example shows a permission derived from the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet1":::
-
]]>
@@ -240,15 +231,6 @@
## Remarks
A copy of a permission object represents the same access to resources as the original permission object.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet2":::
-
]]>
@@ -485,15 +467,6 @@
## Remarks
Custom code that extends security objects needs to implement the and methods to make the objects security-encodable.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet10":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet10":::
-
]]>
The parameter is .
@@ -600,15 +573,6 @@
## Remarks
The intersection of two permissions is a permission that describes the set of operations they both describe in common. Only a demand that passes both original permissions will pass the intersection.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet5":::
-
]]>
The parameter is not and is not an instance of the same class as the current permission.
@@ -665,29 +629,15 @@
The following statements are required to be `true` for all overrides of the method. *X*, *Y*, and *Z* represent custom code access permission objects that are not null references, *U* represents an unrestricted code access permission, and *N* represents an empty permission with a of .
-- *X*.IsSubsetOf(*X*) returns `true`.
-
-- *X*.IsSubsetOf(*Y*) returns the same value as *Y*.IsSubsetOf(*X*) if and only if *X* and *Y* represent the same set of permissions.
-
+- *X*.IsSubsetOf(*X*) returns `true`.
+- *X*.IsSubsetOf(*Y*) returns the same value as *Y*.IsSubsetOf(*X*) if and only if *X* and *Y* represent the same set of permissions.
- If *X*.IsSubsetOf(*Y*) and *Y*.IsSubsetOf(*Z*) both return `true`, *X*.IsSubsetOf(*Z*) returns `true`.
-
-- *X*.IsSubsetOf(*U*) returns `true`.
-
-- *X*.IsSubsetOf(*N*) returns `false`.
-
-- *N*.IsSubsetOf(*X*) returns `true`.
+- *X*.IsSubsetOf(*U*) returns `true`.
+- *X*.IsSubsetOf(*N*) returns `false`.
+- *N*.IsSubsetOf(*X*) returns `true`.
If *X* and *Y* represent custom code access permission objects that are null references, *X*.IsSubsetOf(*Y*) returns `true`. If *Z* is also null, the compound set operation *X*.Union(*Y*).IsSubsetOf(*Z*) also returns `true` because the union of two null permissions is a null permission.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet4":::
-
]]>
The parameter is not and is not of the same type as the current permission.
@@ -1048,15 +998,6 @@
## Remarks
Custom code that extends security objects needs to implement the and methods to make the objects security-encodable.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet11":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet11":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet11":::
-
]]>
@@ -1109,15 +1050,6 @@
## Remarks
The result of a call to is a permission that represents all the operations represented by both the current permission and the specified permission. Any demand that passes either permission passes their union.
-
-
-## Examples
- The following code example shows an override of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp" id="Snippet12":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs" id="Snippet12":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb" id="Snippet12":::
-
]]>
The parameter is not . This method is only supported at this level when passed .
diff --git a/xml/System.Security/IPermission.xml b/xml/System.Security/IPermission.xml
index 9a44cb3a273..060781339ed 100644
--- a/xml/System.Security/IPermission.xml
+++ b/xml/System.Security/IPermission.xml
@@ -93,11 +93,8 @@
Permissions in the common language runtime are objects that describe sets of operations that can be secured for specified resources. A permission object describes operations or access that is subject to security control; it does not represent access or a right to perform operations. Permissions are used by both application code and the .NET Framework security system in the following ways:
- Code requests the permissions it needs in order to run.
-
- The security system policy grants permissions to code in order for it to run.
-
- Code demands that calling code has a permission.
-
- Code overrides the security stack using assert/deny/permit-only.
> [!NOTE]
@@ -106,15 +103,6 @@
> [!IMPORTANT]
> A permission can be accessed by multiple threads. When implementing this interface, you must guarantee that the , , , and method implementations are thread safe.
-
-
-## Examples
- This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1":::
-
]]>
@@ -174,15 +162,6 @@
## Remarks
A copy of a permission represents the same access to resources as the original permission.
-
-
-## Examples
- The following code example demonstrates implementing the method. This code example is part of a larger example provided for the interface.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet4":::
-
]]>
@@ -310,20 +289,9 @@
The following statements are required to be true for all implementations of the method. `X` and `Y` represent object references that are not `null`.
-- `X`.Intersect(`X`) returns a value equal to `X`.
-
-- `X`.Intersect(`Y`) returns the same value as `Y`.Intersect(`X`).
-
-- `X`.Intersect(`null`) returns `null`.
-
-
-
-## Examples
- The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet2":::
+- `X`.Intersect(`X`) returns a value equal to `X`.
+- `X`.Intersect(`Y`) returns the same value as `Y`.Intersect(`X`).
+- `X`.Intersect(`null`) returns `null`.
]]>
@@ -392,23 +360,12 @@
The following statements are required to be true for all implementations of the method. `X`, `Y`, and `Z` represent objects that are not `null`.
-- `X`.IsSubsetOf(`X`) returns `true`.
-
-- `X`.IsSubsetOf(`Y`) returns the same value as `Y`.IsSubsetOf(`X`) if and only if `X` and `Y` represent the same set of permissions.
-
+- `X`.IsSubsetOf(`X`) returns `true`.
+- `X`.IsSubsetOf(`Y`) returns the same value as `Y`.IsSubsetOf(`X`) if and only if `X` and `Y` represent the same set of permissions.
- If `X`.IsSubsetOf(`Y`) and `Y`.IsSubsetOf(`Z`) both return `true`, `X`.IsSubsetOf(`Z`) returns `true`.
If `X` represents an empty object with a permission state of and `Y` represents an object that is `null`, `X`.IsSubsetOf(`Y`) returns `true`. If `Z` is also an empty permission, the compound set operation `X`.Union(Z).IsSubsetOf(Y) also returns `true` because the union of two empty permissions is an empty permission.
-
-
-## Examples
- The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet3":::
-
]]>
The parameter is not and is not of the same type as the current permission.
@@ -475,20 +432,9 @@
The following statements are required to be true for all implementations of the method. `X` and `Y` represent objects that are not `null`.
-- `X`.Union(`X`) returns an object that has the same value as `X`.
-
-- `X`.Union(`Y`) returns an object that has the same value as the object returned by `Y`.Union(`X`).
-
-- `X`.Union(`null`) returns an object that has the same value as `X`.
-
-
-
-## Examples
- The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet5":::
+- `X`.Union(`X`) returns an object that has the same value as `X`.
+- `X`.Union(`Y`) returns an object that has the same value as the object returned by `Y`.Union(`X`).
+- `X`.Union(`null`) returns an object that has the same value as `X`.
]]>
diff --git a/xml/System.Security/PermissionSet.xml b/xml/System.Security/PermissionSet.xml
index a027519be83..2172c99adb3 100644
--- a/xml/System.Security/PermissionSet.xml
+++ b/xml/System.Security/PermissionSet.xml
@@ -98,23 +98,14 @@
Represents a collection that can contain many different types of permissions.
- to perform operations on several different permissions as a group.
-
-
-
-## Examples
- The following code example demonstrates the use of the class and members.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet1":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet1":::
-
+ You can use to perform operations on several different permissions as a group.
+
]]>
@@ -175,22 +166,13 @@
One of the enumeration values that specifies the permission set's access to resources.
Initializes a new instance of the class with the specified .
- interface, while `None` allows no permissions.
-
- Use on an empty to define the set in greater detail.
-
-
-
-## Examples
- The following code example shows the use of the constructor to create a permission set with a permission state of . This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet2":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet2":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet2":::
-
+ interface, while `None` allows no permissions.
+
+ Use on an empty to define the set in greater detail.
+
]]>The parameter is not a valid .
@@ -243,14 +225,14 @@
The set from which to take the value of the new , or to create an empty .
Initializes a new instance of the class with initial values taken from the parameter.
- contains copies of the permissions contained in the specified .
-
+ contains copies of the permissions contained in the specified .
+
> [!NOTE]
-> This is equivalent to when the `permSet` parameter is not `null`.
-
+> This is equivalent to when the `permSet` parameter is not `null`.
+
]]>
@@ -311,20 +293,11 @@
Adds a specified permission to the .The union of the permission added and any permission of the same type that already exists in the .
- , the new permission is the union of the existing permission object and the specified permission object. For example, if a permission that implements is added to an , the resulting union is the original `Unrestricted` .
-
-
-
-## Examples
- The following code example shows the use of the method to add a permission to a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet3":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet3":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet3":::
-
+ , the new permission is the union of the existing permission object and the specified permission object. For example, if a permission that implements is added to an , the resulting union is the original `Unrestricted` .
+
]]>The method is called from a .
@@ -387,13 +360,13 @@
Adds a specified permission to the .The union of the permission added and any permission of the same type that already exists in the , or if is .
- method is the implementation for the method.
-
- If a permission of the same type as the added permission already exists in the , the new permission is the union of the existing permission object and the specified permission object. For example, if a permission that implements is added to an , the resulting union is the original `Unrestricted` .
-
+ method is the implementation for the method.
+
+ If a permission of the same type as the added permission already exists in the , the new permission is the union of the existing permission object and the specified permission object. For example, if a permission that implements is added to an , the resulting union is the original `Unrestricted` .
+
]]>The method is called from a .
@@ -456,20 +429,20 @@
Declares that the calling code can access the resource protected by a permission demand through the code that calls this method, even if callers higher in the stack have not been granted permission to access the resource. Using can create security vulnerabilities.
- can be active on a frame. is only effective for granted permissions. Call the or method to cancel an active .
-
+ can be active on a frame. is only effective for granted permissions. Call the or method to cancel an active .
+
> [!CAUTION]
-> Because calling the method removes the requirement that all code in the call chain must be granted permission to access the specified resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore, it should be used with great caution.
-
+> Because calling the method removes the requirement that all code in the call chain must be granted permission to access the specified resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore, it should be used with great caution.
+
]]>
- The instance asserted has not been granted to the asserting code.
-
- -or-
-
+ The instance asserted has not been granted to the asserting code.
+
+ -or-
+
There is already an active for the current frame.Using the Assert Method
@@ -521,18 +494,7 @@
Gets a value indicating whether the contains permissions that are not derived from . if the contains permissions that are not derived from ; otherwise, .
-
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet9":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet9":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet9":::
-
- ]]>
-
+ To be added.
@@ -599,11 +561,11 @@
Converts an encoded from one XML encoding format to another XML encoding format.An encrypted permission set with the specified output format.
- In all cases.
@@ -656,20 +618,11 @@
Creates a copy of the .A copy of the .
- represents the same access to resources as the original object. Changes made to the copy do not affect the original permission set.
-
-
-
-## Examples
- The following code example shows the use of the method to create a copy of a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet20":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet20":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet20":::
-
+ represents the same access to resources as the original object. Changes made to the copy do not affect the original permission set.
+
]]>
@@ -788,20 +741,11 @@
Gets the number of permission objects contained in the permission set.The number of permission objects contained in the .
- property to get the number of permission objects in a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet5":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet5":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet5":::
-
+
@@ -863,24 +807,15 @@
Forces a at run time if all callers higher in the call stack have not been granted the permissions specified by the current instance.
- on a to ensure that all callers have all permissions in the set with one operation.
-
- The permissions of the code that calls this method are not examined; the check begins from the immediate caller of that code and proceeds up the stack. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack. succeeds only if no is thrown.
-
- If the contains permissions that do not inherit from , the `Demand` methods of those permissions are called as well.
-
-
-
-## Examples
- The following code example shows the use of the method to demand all the permissions in a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet4":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet4":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet4":::
-
+ on a to ensure that all callers have all permissions in the set with one operation.
+
+ The permissions of the code that calls this method are not examined; the check begins from the immediate caller of that code and proceeds up the stack. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack. succeeds only if no is thrown.
+
+ If the contains permissions that do not inherit from , the `Demand` methods of those permissions are called as well.
+
]]>A caller in the call chain does not have the permission demanded.
@@ -951,15 +886,15 @@
Causes any that passes through the calling code for a permission that has an intersection with a permission of a type contained in the current to fail.
- can limit the liability of the programmer or help prevent accidental security vulnerabilities because it helps prevent the method that calls from being used to access the resource protected by the denied permission. If a method calls on a permission, and if a for that permission is invoked by a caller lower in the call stack, that security check fails when it reaches the .
-
- is ignored for a permission that is not granted because a demand for that permission cannot succeed.
-
+ can limit the liability of the programmer or help prevent accidental security vulnerabilities because it helps prevent the method that calls from being used to access the resource protected by the denied permission. If a method calls on a permission, and if a for that permission is invoked by a caller lower in the call stack, that security check fails when it reaches the .
+
+ is ignored for a permission that is not granted because a demand for that permission cannot succeed.
+
]]>A previous call to has already restricted the permissions for the current stack frame.
@@ -1028,13 +963,13 @@
if the specified object is equal to the current object; otherwise, .
- object or a object. If `obj` is a , the name and description are ignored.
-
- For more information, see .
-
+ object or a object. If `obj` is a , the name and description are ignored.
+
+ For more information, see .
+
]]>
@@ -1090,23 +1025,12 @@
The XML encoding to use to reconstruct the security object.
Reconstructs a security object with a specified state from an XML encoding.
-
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet17":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet17":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet17":::
-
- ]]>
-
+ To be added.The parameter is .
- The parameter is not a valid permission element.
-
- -or-
-
+ The parameter is not a valid permission element.
+
+ -or-
+
The parameter's version number is not supported.
@@ -1162,20 +1086,11 @@
Returns an enumerator for the permissions of the set.An enumerator object for the permissions of the set.
- method to list all the permissions in a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet18":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet18":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet18":::
-
+
@@ -1227,11 +1142,11 @@
Returns an enumerator for the permissions of the set.An enumerator object for the permissions of the set.
- method is the implementation for the method.
-
+ method is the implementation for the method.
+
]]>
@@ -1288,11 +1203,11 @@
Gets a hash code for the object that is suitable for use in hashing algorithms and data structures such as a hash table.A hash code for the current object.
- objects.
-
+ objects.
+
]]>
@@ -1353,11 +1268,11 @@
Gets a permission object of the specified type, if it exists in the set.A copy of the permission object of the type specified by the parameter contained in the , or if none exists.
- . Although an `Unrestricted` effectively contains all permissions, it does not have any actual instances to return.
-
+ . Although an `Unrestricted` effectively contains all permissions, it does not have any actual instances to return.
+
]]>
@@ -1413,13 +1328,13 @@
Gets a permission object of the specified type, if it exists in the set.A copy of the permission object, of the type specified by the parameter, contained in the , or if none exists.
- method is the implementation for the method.
-
- The method returns `null` for an `Unrestricted` . Although an `Unrestricted` effectively contains all permissions, it does not have any actual instances to return.
-
+ method is the implementation for the method.
+
+ The method returns `null` for an `Unrestricted` . Although an `Unrestricted` effectively contains all permissions, it does not have any actual instances to return.
+
]]>
@@ -1486,22 +1401,13 @@
Creates and returns a permission set that is the intersection of the current and the specified .A new permission set that represents the intersection of the current and the specified target. This object is if the intersection is empty.
- . Permission types that exist in only one of the two sets are excluded from the resulting set.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet12":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet12":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet12":::
-
+ . Permission types that exist in only one of the two sets are excluded from the resulting set.
+
]]>
@@ -1565,11 +1471,11 @@
if the is empty; otherwise, .
- can be empty and yet contain instances of permissions if those permissions are in the fully-restricted state. Permissions are in a fully restricted state if their `IsSubsetOf` methods return `true` when `null` is passed as a parameter.
-
+ can be empty and yet contain instances of permissions if those permissions are in the fully-restricted state. Permissions are in a fully restricted state if their `IsSubsetOf` methods return `true` when `null` is passed as a parameter.
+
]]>
@@ -1620,20 +1526,11 @@
Gets a value indicating whether the collection is read-only.Always .
- cannot be read-only, so this property is always `false`.
-
-
-
-## Examples
- The following code example shows the value returned by the property. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet7":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet7":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet7":::
-
+ cannot be read-only, so this property is always `false`.
+
]]>
@@ -1701,20 +1598,11 @@
if the current is a subset of the parameter; otherwise, .
- is a subset of the target if all demands that succeed for the also succeed for the target. That is, the target contains at least the permissions contained in the subset.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet11":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet11":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet11":::
-
+ is a subset of the target if all demands that succeed for the also succeed for the target. That is, the target contains at least the permissions contained in the subset.
+
]]>
@@ -1768,22 +1656,13 @@
Gets a value indicating whether the collection is guaranteed to be thread safe.Always .
- does not automatically handle thread safety, so this property is always `false`.
-
- This method is required to support .
-
-
-
-## Examples
- The following code example shows the value returned by the property. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet6":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet6":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet6":::
-
+ does not automatically handle thread safety, so this property is always `false`.
+
+ This method is required to support .
+
]]>
@@ -1841,20 +1720,11 @@
if the is ; otherwise, .
- effectively contains all permissions that implement the interface.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet19":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet19":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet19":::
-
+ effectively contains all permissions that implement the interface.
+
]]>
@@ -1916,13 +1786,13 @@
Causes any that passes through the calling code for any that is not a subset of the current to fail.
- is similar to , in that both cause stack walks to fail when they would otherwise succeed. The difference is that specifies permissions that will cause the stack walk to fail, but specifies the only permissions that do not cause the stack walk to fail. Call this method to ensure that your code can be used to access only the specified resources.
-
- is ignored for a permission not granted because a demand for that permission cannot succeed. However, if code lower on the call stack later calls for that permission, a is thrown when the stack walk reaches the code that tried to call . This is because the code that called has not been granted the permission, even though it called for that permission. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.
-
+ is similar to , in that both cause stack walks to fail when they would otherwise succeed. The difference is that specifies permissions that will cause the stack walk to fail, but specifies the only permissions that do not cause the stack walk to fail. Call this method to ensure that your code can be used to access only the specified resources.
+
+ is ignored for a permission not granted because a demand for that permission cannot succeed. However, if code lower on the call stack later calls for that permission, a is thrown when the stack walk reaches the code that tried to call . This is because the code that called has not been granted the permission, even though it called for that permission. The call stack is typically represented as growing down, so that methods higher in the call stack call methods lower in the call stack.
+
]]>
@@ -1983,30 +1853,13 @@
Removes a permission of a certain type from the set.The permission removed from the set.
- [!IMPORTANT]
-> You cannot remove permissions from an unrestricted permission set. The permission set remains unrestricted after you attempt to remove the permission, and an exception is not thrown.
-
- The following C# code attempts to remove the from the `FullTrust` permission set, but the permission is not removed.
-
-```
-PolicyLevel myPol = PolicyLevel.CreateAppDomainLevel();
-PermissionSet myPermSet = myPol.GetNamedPermissionSet("FullTrust");
-myPermSet.RemovePermission(typeof(FileIOPermission));
-```
-
-
-
-## Examples
- The following code example shows the use of the method to remove a from a permission set. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet15":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet15":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet15":::
-
+> You cannot remove permissions from an unrestricted permission set. The permission set remains unrestricted after you attempt to remove the permission, and no exception is thrown.
+
]]>The method is called from a .
@@ -2063,14 +1916,14 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Removes a permission of a certain type from the set.The permission removed from the set.
- method is the implementation for the method.
-
+ method is the implementation for the method.
+
> [!IMPORTANT]
-> You cannot remove permissions from an unrestricted permission set. The permission set remains unrestricted after you attempt to remove the permission, and an exception is not thrown.
-
+> You cannot remove permissions from an unrestricted permission set. The permission set remains unrestricted after you attempt to remove the permission, and an exception is not thrown.
+
]]>The method is called from a .
@@ -2127,11 +1980,11 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Causes any previous for the current frame to be removed and no longer be in effect.
- for the current frame, an is thrown.
-
+ for the current frame, an is thrown.
+
]]>There is no previous for the current frame.
@@ -2193,20 +2046,11 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Sets a permission to the , replacing any existing permission of the same type.The set permission.
- and replaces it with the `perm` parameter. If a permission that implements is set on a that is , the resulting is no longer `Unrestricted`.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet16":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet16":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet16":::
-
+ and replaces it with the `perm` parameter. If a permission that implements is set on a that is , the resulting is no longer `Unrestricted`.
+
]]>The method is called from a .
@@ -2263,13 +2107,13 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Sets a permission to the , replacing any existing permission of the same type.The set permission.
- method is the implementation for the method.
-
- This method removes any existing permission object of the same type from the and replaces it with the `perm` parameter. If a permission that implements is set on a that is , the resulting is no longer `Unrestricted`.
-
+ method is the implementation for the method.
+
+ This method removes any existing permission object of the same type from the and replaces it with the `perm` parameter. If a permission that implements is set on a that is , the resulting is no longer `Unrestricted`.
+
]]>The method is called from a .
@@ -2330,20 +2174,11 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Gets the root object of the current collection.The root object of the current collection.
- .
-
-
-
-## Examples
- The following code example shows the use of property to get the root object of the current collection. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet8":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet8":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet8":::
-
+ .
+
]]>
@@ -2456,20 +2291,11 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Returns a string representation of the .A representation of the .
- .
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet10":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet10":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet10":::
-
+ .
+
]]>
@@ -2524,18 +2350,7 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Creates an XML encoding of the security object and its current state.An XML encoding of the security object, including any state information.
-
- method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet17":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet17":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet17":::
-
- ]]>
-
+ To be added.
@@ -2600,20 +2415,11 @@ myPermSet.RemovePermission(typeof(FileIOPermission));
Creates a that is the union of the current and the specified .A new permission set that represents the union of the current and the specified .
- is a that represents all the operations represented by the current as well as all the operations represented by the specified . If either set is `Unrestricted`, the union is `Unrestricted` as well.
-
-
-
-## Examples
- The following code example shows the use of the method. This code example is part of a larger example provided for the class.
-
- :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp" id="Snippet13":::
- :::code language="csharp" source="~/snippets/csharp/System.Security/PermissionSet/Overview/permissionset.cs" id="Snippet13":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb" id="Snippet13":::
-
+ is a that represents all the operations represented by the current as well as all the operations represented by the specified . If either set is `Unrestricted`, the union is `Unrestricted` as well.
+
]]>
diff --git a/xml/System.Security/SecurityContext.xml b/xml/System.Security/SecurityContext.xml
index 84f0bc50f81..adb32fe1e4d 100644
--- a/xml/System.Security/SecurityContext.xml
+++ b/xml/System.Security/SecurityContext.xml
@@ -49,8 +49,8 @@
Encapsulates and propagates all security-related data for execution contexts transferred across threads. This class cannot be inherited.
- [!NOTE]
> This type is marked obsolete starting in .NET 6.
- A object captures all security-related information for a logical thread, including the information contained in the and objects. This configuration allows the Windows identity and the security elements on the stack to be propagated automatically when the is copied and transferred across asynchronous threads.
-
+ A object captures all security-related information for a logical thread, including the information contained in the and objects. This configuration allows the Windows identity and the security elements on the stack to be propagated automatically when the is copied and transferred across asynchronous threads.
+
> [!NOTE]
-> The common language runtime (CLR) is aware of impersonation operations performed using only managed code, not of impersonation performed outside of managed code, such as through platform invoke to unmanaged code or through direct calls to Win32 functions. Only managed objects can flow across asynchronous points, unless the `alwaysFlowImpersonationPolicy` element has been set to `true` (``). Setting the `alwaysFlowImpersonationPolicy` element to `true` specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed. For more information about flowing unmanaged impersonation across asynchronous points, see [<alwaysFlowImpersonationPolicy> Element](/dotnet/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element).
-
- The is part of the larger and flows or migrates when the flows or migrates.
-
+> The common language runtime (CLR) is aware of impersonation operations performed using only managed code, not of impersonation performed outside of managed code, such as through platform invoke to unmanaged code or through direct calls to Win32 functions. Only managed objects can flow across asynchronous points, unless the `alwaysFlowImpersonationPolicy` element has been set to `true` (``). Setting the `alwaysFlowImpersonationPolicy` element to `true` specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed. For more information about flowing unmanaged impersonation across asynchronous points, see [<alwaysFlowImpersonationPolicy> Element](/dotnet/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element).
+
+ The is part of the larger and flows or migrates when the flows or migrates.
+
> [!IMPORTANT]
-> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic.
-
+> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic.
+
]]>
@@ -111,11 +111,11 @@
Captures the security context for the current thread.The security context for the current thread.
- consists of the and the for the executing thread.
-
+ consists of the and the for the executing thread.
+
]]>.NET 5+ (including .NET Core): In all cases.
@@ -160,11 +160,11 @@
Creates a copy of the current security context.The security context for the current thread.
- to multiple threads.
-
+ to multiple threads.
+
]]>The current security context has been previously used, was marshaled across application domains, or was not acquired through the method.
@@ -211,16 +211,16 @@
Releases all resources used by the current instance of the class.
- . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying.
-
- For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose).
-
+ . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying.
+
+ For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose).
+
> [!NOTE]
-> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method.
-
+> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method.
+
]]>.NET 5+ (including .NET Core): In all cases.
@@ -260,11 +260,11 @@
if the flow has been suppressed; otherwise, .
- method is used by infrastructure components to determine whether to transfer the information during asynchronous operations.
-
+ method is used by infrastructure components to determine whether to transfer the information during asynchronous operations.
+
]]>.NET 5+ (including .NET Core): In all cases.
@@ -304,11 +304,11 @@
if the flow has been suppressed; otherwise, .
- method is used by infrastructure components to determine whether to transfer the Windows identity information when the migrates during asynchronous operations.
-
+ method is used by infrastructure components to determine whether to transfer the Windows identity information when the migrates during asynchronous operations.
+
]]>.NET 5+ (including .NET Core): In all cases.
@@ -352,11 +352,11 @@
Restores the flow of the security context across asynchronous threads.
- method is called by the method to reverse the effect of a prior method call.
-
+ method is called by the method to reverse the effect of a prior method call.
+
]]>The security context is or an empty string.
@@ -408,28 +408,22 @@
The object to pass to the callback method.
Runs the specified method in the specified security context on the current thread.
- method to execute a method in a specified security context.
-
- :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityContext/Run/form1.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecurityContext.Run/VB/form1.vb" id="Snippet1":::
-
+
]]>
- is .
-
- -or-
-
- was not acquired through a capture operation.
-
- -or-
-
+ is .
+
+ -or-
+
+ was not acquired through a capture operation.
+
+ -or-
+
has already been used as the argument to a method call..NET 5+ (including .NET Core): In all cases.
@@ -473,17 +467,17 @@
Suppresses the flow of the security context across asynchronous threads.An structure for restoring the flow.
- information on the current thread for asynchronous operations.
-
- The common language runtime (CLR) is only aware of the impersonation operations performed using managed code. The CLR has no knowledge of impersonation performed outside of managed code, such as platform invokes to unmanaged code that does the impersonation, or through calls to Win32 functions. To flow identity across asynchronous points you must use the managed and methods.
-
- Use the method on the returned structure to return the object to its previous state.
-
- This method is protected with a for permission. A fully trusted component can call this method to suppress the flow of the information during asynchronous calls. When the flow is suppressed, the method returns `null`.
-
+ information on the current thread for asynchronous operations.
+
+ The common language runtime (CLR) is only aware of the impersonation operations performed using managed code. The CLR has no knowledge of impersonation performed outside of managed code, such as platform invokes to unmanaged code that does the impersonation, or through calls to Win32 functions. To flow identity across asynchronous points you must use the managed and methods.
+
+ Use the method on the returned structure to return the object to its previous state.
+
+ This method is protected with a for permission. A fully trusted component can call this method to suppress the flow of the information during asynchronous calls. When the flow is suppressed, the method returns `null`.
+
]]>.NET 5+ (including .NET Core): In all cases.
@@ -528,16 +522,16 @@
Suppresses the flow of the Windows identity portion of the current security context across asynchronous threads.A structure for restoring the flow.
- migrates across asynchronous threads.
-
- Use the method on the returned structure to return the object to its previous state.
-
+ migrates across asynchronous threads.
+
+ Use the method on the returned structure to return the object to its previous state.
+
> [!NOTE]
-> The common language runtime (CLR) is aware of impersonation operations performed using only managed code, not of impersonation performed outside of managed code, such as through platform invoke to unmanaged code or through direct calls to Win32 functions. Only managed objects can flow across asynchronous points, unless the `alwaysFlowImpersonationPolicy` element has been set to `true` (``). Setting the `alwaysFlowImpersonationPolicy` element to `true` specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed. For more information about flowing unmanaged impersonation across asynchronous points, see [\ Element](/dotnet/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element).
-
+> The common language runtime (CLR) is aware of impersonation operations performed using only managed code, not of impersonation performed outside of managed code, such as through platform invoke to unmanaged code or through direct calls to Win32 functions. Only managed objects can flow across asynchronous points, unless the `alwaysFlowImpersonationPolicy` element has been set to `true` (``). Setting the `alwaysFlowImpersonationPolicy` element to `true` specifies that the Windows identity always flows across asynchronous points, regardless of how impersonation was performed. For more information about flowing unmanaged impersonation across asynchronous points, see [\ Element](/dotnet/framework/configure-apps/file-schema/runtime/alwaysflowimpersonationpolicy-element).
+
]]>.NET 5+ (including .NET Core): In all cases.
diff --git a/xml/System.Security/SecurityManager.xml b/xml/System.Security/SecurityManager.xml
index 464c2df19b3..dbce236d317 100644
--- a/xml/System.Security/SecurityManager.xml
+++ b/xml/System.Security/SecurityManager.xml
@@ -215,27 +215,19 @@
>
> The following table shows the permission sets that are returned for each zone.
-|Zone|Permission set|
-|----------|--------------------|
-||`FullTrust`|
-||`LocalIntranet`|
-||`Internet`|
-||`Internet`|
-||None|
-||None|
+| Zone | Permission set |
+|------------------------------------------------|-----------------|
+| | `FullTrust` |
+| | `LocalIntranet` |
+| | `Internet` |
+| | `Internet` |
+| | None |
+| | None |
Other evidence, such as or , may be considered.
The returned permission set can be used by a sandbox to run the application. Note that this method does not specify policy, but helps a host to determine whether the permission set requested by an application is reasonable. This method can be used to map a zone to a sandbox.
-
-
-## Examples
- The following example shows how to use the method to obtain the permission set for a sandboxed application. For more information about running an application in a sandbox, see [How to: Run Partially Trusted Code in a Sandbox](/dotnet/framework/misc/how-to-run-partially-trusted-code-in-a-sandbox).
-
- :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityManager/GetStandardSandbox/program.cs" id="Snippet1":::
- :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SandboxingAPIs/VB/program.vb" id="Snippet1":::
-
]]>
From 858f158faf72e77d2c84691fef0928722ed99126 Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Fri, 20 Jun 2025 19:04:52 +0200
Subject: [PATCH 2/3] delete referenced snippet files
---
.../IsolatedStoragePermissionAttribute.cpp | 92 ---
.../CPP/permissionset.cpp | 164 ------
.../CPP/nameidpermissionattribute.cpp | 59 --
.../CPP/dataprotect.cpp | 234 --------
.../CPP/fileiopermission.cpp | 534 ------------------
.../CPP/remarks.cpp | 95 ----
.../CPP/fileiopermissionattribute.cpp | 102 ----
.../CPP/gacidentitypermission.cpp | 260 ---------
.../CPP/gacidentitypermissionattribute.cpp | 51 --
.../CPP/hostprotectionattribute.cpp | 243 --------
.../CPP/keycontainerpermission.cpp | 296 ----------
.../CPP/nameidpermission.cpp | 280 ---------
.../CPP/publisheridentitypermission.cpp | 166 ------
.../CPP/securitypermissionattribute.cpp | 457 ---------------
.../CPP/storepermission.cpp | 143 -----
.../CPP/strongnameidentity.cpp | 244 --------
.../CPP/uipermission.cpp | 178 ------
.../CPP/urlidentity.cpp | 121 ----
.../CPP/members.cpp | 314 ----------
.../CPP/members.cpp | 359 ------------
.../system.Security.Policy.Gac/CPP/gac.cpp | 39 --
.../Overview/nameidpermission.cs | 216 -------
.../Overview/nameidpermissionattribute.cs | 47 --
.../GetPathList/fileiopermission.cs | 514 -----------------
.../FileIOPermission/GetPathList/remarks.cs | 97 ----
.../Overview/nameidpermission.cs | 240 --------
.../VB/permissionset.vb | 138 -----
.../VB/nameidpermissionattribute.vb | 45 --
.../VB/dataprotect.vb | 172 ------
.../VB/environmentpermission.vb | 258 ---------
.../VB/fileiopermission.vb | 480 ----------------
.../VB/remarks.vb | 87 ---
.../VB/fileiopermissionattribute.vb | 84 ---
.../VB/gacidentitypermission.vb | 214 -------
.../VB/gacidentitypermissionattribute.vb | 40 --
.../VB/hostprotectionattribute.vb | 219 -------
.../VB/Form1.vb | 270 ---------
.../VB/nameidpermission.vb | 217 -------
.../VB/Form1.vb | 319 -----------
.../VB/publisheridentitypermission.vb | 116 ----
.../VB/reflectionpermission.vb | 122 ----
.../VB/registrypermission.vb | 159 ------
.../VB/securitypermissionattribute.vb | 324 -----------
.../VB/program.vb | 125 ----
.../VB/strongnameidentity.vb | 218 -------
.../VB/uipermission.vb | 165 ------
.../VB/urlidentity.vb | 123 ----
.../VB/zoneidentity.vb | 140 -----
.../VB/Form1.vb | 456 ---------------
.../VB/Form1.vb | 487 ----------------
.../system.Security.Policy.Gac/VB/gac.vb | 39 --
.../VB/form1.vb | 19 -
.../vb/remarks.vb | 31 -
53 files changed, 10612 deletions(-)
delete mode 100644 snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/CPP/nameidpermissionattribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/CPP/publisheridentitypermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/CPP/storepermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp
delete mode 100644 snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs
delete mode 100644 snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermissionattribute.cs
delete mode 100644 snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs
delete mode 100644 snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs
delete mode 100644 snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/VB/nameidpermissionattribute.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/VB/publisheridentitypermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/VB/program.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecurityContext.Run/VB/form1.vb
delete mode 100644 snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb
diff --git a/snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp b/snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp
deleted file mode 100644
index 99ec465e315..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/IsolatedStoragePermissionAttribute/cpp/IsolatedStoragePermissionAttribute.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-//Types:System.Security.Permissions.IsolatedStorageContainment (enum)
-//Types:System.Security.Permissions.IsolatedStoragePermissionAttribute
-//Types:System.Security.Permissions.SecurityAction
-//
-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.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp
deleted file mode 100644
index cef1b5fb817..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.PermissionSet/CPP/permissionset.cpp
+++ /dev/null
@@ -1,164 +0,0 @@
-
-//
-// This sample demonstrates the use of the PermissionSet class.
-using namespace System;
-using namespace System::Reflection;
-using namespace System::Security::Permissions;
-using namespace System::Security;
-using namespace System::IO;
-using namespace System::Collections;
-void PermissionSetDemo()
-{
- Console::WriteLine( "Executing PermissionSetDemo" );
- try
- {
- //
- // Open a new PermissionSet.
- PermissionSet^ ps1 = gcnew PermissionSet( PermissionState::None );
-
- Console::WriteLine( "Adding permission to open a file from a file dialog box." );
-
- //
- // Add a permission to the permission set.
- ps1->AddPermission( gcnew FileDialogPermission( FileDialogPermissionAccess::Open ) );
- //
-
- Console::WriteLine( "Demanding permission to open a file." );
- ps1->Demand();
- Console::WriteLine( "Demand succeeded." );
- //
- Console::WriteLine( "Adding permission to save a file from a file dialog box." );
- ps1->AddPermission( gcnew FileDialogPermission( FileDialogPermissionAccess::Save ) );
- Console::WriteLine( "Demanding permission to open and save a file." );
- ps1->Demand();
- Console::WriteLine( "Demand succeeded." );
- Console::WriteLine( "Adding permission to read environment variable USERNAME." );
- ps1->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Read,"USERNAME" ) );
- ps1->Demand();
- Console::WriteLine( "Demand succeeded." );
- Console::WriteLine( "Adding permission to read environment variable COMPUTERNAME." );
- ps1->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Read,"COMPUTERNAME" ) );
-
- //
- // Demand all the permissions in the set.
- Console::WriteLine( "Demand all permissions." );
- ps1->Demand();
- //
-
- Console::WriteLine( "Demand succeeded." );
-
- //
- // Display the number of permissions in the set.
- Console::WriteLine( "Number of permissions = {0}", ps1->Count );
- //
-
- //
- // Display the value of the IsSynchronized property.
- Console::WriteLine( "IsSynchronized property = {0}", ps1->IsSynchronized );
- //
-
- //
- // Display the value of the IsReadOnly property.
- Console::WriteLine( "IsReadOnly property = {0}", ps1->IsReadOnly );
- //
-
- //
- // Display the value of the SyncRoot property.
- Console::WriteLine( "SyncRoot property = {0}", ps1->SyncRoot );
- //
-
- //
- // Display the result of a call to the ContainsNonCodeAccessPermissions method.
- // Gets a value indicating whether the PermissionSet contains permissions
- // that are not derived from CodeAccessPermission.
- // Returns true if the PermissionSet contains permissions that are not
- // derived from CodeAccessPermission; otherwise, false.
- Console::WriteLine( "ContainsNonCodeAccessPermissions method returned {0}", ps1->ContainsNonCodeAccessPermissions() );
- //
-
- //
- Console::WriteLine( "Value of the permission set ToString = \n{0}", ps1->ToString() );
- //
-
- PermissionSet^ ps2 = gcnew PermissionSet( PermissionState::None );
-
- //
- // Create a second permission set and compare it to the first permission set.
- ps2->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Read,"USERNAME" ) );
- ps2->AddPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::Write,"COMPUTERNAME" ) );
- IEnumerator^ list = ps1->GetEnumerator();
- Console::WriteLine("Permissions in first permission set:");
- while (list->MoveNext())
- Console::WriteLine(list->Current->ToString());
- Console::WriteLine( "Second permission IsSubsetOf first permission = {0}", ps2->IsSubsetOf( ps1 ) );
- //
-
- //
- // Display the intersection of two permission sets.
- PermissionSet^ ps3 = ps2->Intersect( ps1 );
- Console::WriteLine( "The intersection of the first permission set and the second permission set = {0}", ps3 );
- //
-
- // Create a new permission set.
- PermissionSet^ ps4 = gcnew PermissionSet( PermissionState::None );
- ps4->AddPermission( gcnew FileIOPermission( FileIOPermissionAccess::Read,"C:\\Temp\\Testfile.txt" ) );
- ps4->AddPermission( gcnew FileIOPermission( static_cast(FileIOPermissionAccess::Read | FileIOPermissionAccess::Write | FileIOPermissionAccess::Append),"C:\\Temp\\Testfile.txt" ) );
- //
-
- // Display the union of two permission sets.
- PermissionSet^ ps5 = ps3->Union( ps4 );
- Console::WriteLine( "The union of permission set 3 and permission set 4 = {0}", ps5 );
- //
-
- //
- // Remove FileIOPermission from the permission set.
- ps5->RemovePermission( FileIOPermission::typeid );
- Console::WriteLine( "The last permission set after removing FileIOPermission = {0}", ps5 );
- //
-
- //
- // Change the permission set using SetPermission.
- ps5->SetPermission( gcnew EnvironmentPermission( EnvironmentPermissionAccess::AllAccess,"USERNAME" ) );
- Console::WriteLine( "Permission set after SetPermission = {0}", ps5 );
- //
-
- //
- // Display result of ToXml and FromXml operations.
- PermissionSet^ ps6 = gcnew PermissionSet( PermissionState::None );
- ps6->FromXml( ps5->ToXml() );
- Console::WriteLine( "Result of ToFromXml = {0}\n", ps6 );
- //
-
- //
- // Display results of PermissionSet::GetEnumerator.
- IEnumerator^ psEnumerator = ps1->GetEnumerator();
- while ( psEnumerator->MoveNext() )
- {
- Console::WriteLine( psEnumerator->Current );
- }
- //
-
- //
- // Check for an unrestricted permission set.
- PermissionSet^ ps7 = gcnew PermissionSet( PermissionState::Unrestricted );
- Console::WriteLine( "Permission set is unrestricted = {0}", ps7->IsUnrestricted() );
- //
-
- //
- // Create and display a copy of a permission set.
- ps7 = ps5->Copy();
- Console::WriteLine( "Result of copy = {0}", ps7 );
- //
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
-}
-
-int main()
-{
- PermissionSetDemo();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/CPP/nameidpermissionattribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/CPP/nameidpermissionattribute.cpp
deleted file mode 100644
index 67c13f7830e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/CPP/nameidpermissionattribute.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#using "NameIdPermission.dll"
-//
-using namespace System;
-using namespace System::IO;
-using namespace System::Runtime::Remoting;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Reflection;
-using namespace MyPermission;
-
-// Use the command line option '/keyfile' or appropriate project settings to sign this assembly.
-[assembly:System::Security::AllowPartiallyTrustedCallersAttribute];
-[AttributeUsage(AttributeTargets::Method|AttributeTargets::Constructor|AttributeTargets::Class|AttributeTargets::Struct|AttributeTargets::Assembly,AllowMultiple=true,Inherited=false)]
-[Serializable]
-public ref class NameIdPermissionAttribute: public CodeAccessSecurityAttribute
-{
-private:
- String^ m_Name;
- bool m_unrestricted;
-
-public:
- NameIdPermissionAttribute( SecurityAction action )
- : CodeAccessSecurityAttribute( action )
- {
- m_Name = nullptr;
- m_unrestricted = false;
- }
-
-
- property String^ Name
- {
- String^ get()
- {
- return m_Name;
- }
-
- void set( String^ value )
- {
- m_Name = value;
- }
-
- }
- virtual IPermission^ CreatePermission() override
- {
- if ( m_unrestricted )
- {
- throw gcnew ArgumentException( "Unrestricted permissions not allowed in identity permissions." );
- }
- else
- {
- if ( m_Name == nullptr )
- return gcnew NameIdPermission( PermissionState::None );
- return gcnew NameIdPermission( m_Name );
- }
- }
-
-};
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp
deleted file mode 100644
index e1cfddf9959..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/CPP/dataprotect.cpp
+++ /dev/null
@@ -1,234 +0,0 @@
-
-//
-#using
-
-using namespace System;
-using namespace System::Security::Permissions;
-using namespace System::Security::Cryptography;
-using namespace System::Security;
-using namespace System::IO;
-
-[assembly:DataProtectionPermissionAttribute(
-SecurityAction::RequestMinimum,
-Flags=DataProtectionPermissionFlags::ProtectData)];
-public ref class DataProtect
-{
-private:
-
- // Create a byte array for additional entropy when using the
- // Protect and Unprotect methods.
- static array^ s_additionalEntropy = {9,8,7,6,5};
- static array^ encryptedSecret;
- static array^ originalData;
-
-public:
- static void Main()
- {
-
- //
- Console::WriteLine( "Creating a permission with the Flags property ="
- " ProtectData." );
- DataProtectionPermission ^ sp = gcnew DataProtectionPermission( DataProtectionPermissionFlags::ProtectData );
-
- ProtectData();
- //
- sp->PermitOnly();
- // The following code results in an exception due to an attempt
- // to unprotect data.
- UnprotectData();
-
- // Remove the restrictive permission.
- CodeAccessPermission::RevertPermitOnly();
-
- // The untprotect call will now succeed.
- UnprotectData();
-
- // Demonstrate the behavior of the class members.
- ShowMembers();
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadKey();
- return;
- }
-
-
-private:
-
-
- // The following method is intended to demonstrate only the behavior of
- // DataProtectionPermission class members,and not their practical usage.
- // Most properties and methods in this class are used for the resolution
- // and enforcement of security policy by the security infrastructure code.
- static void ShowMembers()
- {
- Console::WriteLine( "Creating four DataProtectionPermissions" );
- Console::WriteLine( "Creating the first permission with the Flags "
- "property = ProtectData." );
- DataProtectionPermission ^ sp1 = gcnew DataProtectionPermission( DataProtectionPermissionFlags::ProtectData );
- Console::WriteLine( "Creating the second permission with the Flags "
- "property = AllFlags." );
- DataProtectionPermission ^ sp2 = gcnew DataProtectionPermission( DataProtectionPermissionFlags::AllFlags );
- Console::WriteLine( "Creating the third permission with a permission "
- "state = Unrestricted." );
-
- //
- DataProtectionPermission ^ sp3 = gcnew DataProtectionPermission( PermissionState::Unrestricted );
-
- //
- Console::WriteLine( "Creating the fourth permission with a permission"
- " state = None." );
- DataProtectionPermission ^ sp4 = gcnew DataProtectionPermission( PermissionState::None );
-
- //
- bool rc = sp2->IsSubsetOf( sp3 );
- Console::WriteLine( "Is the permission with all flags set (AllFlags) "
- "a subset of \n \tthe permission with an Unrestricted "
- "permission state? {0}", (rc ? (String^)"Yes" : "No") );
- rc = sp1->IsSubsetOf( sp2 );
- Console::WriteLine( "Is the permission with ProtectData access a "
- "subset of the permission with \n"
- "\tAllFlags set? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- rc = sp3->IsUnrestricted();
- Console::WriteLine( "Is the third permission unrestricted? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- Console::WriteLine( "Copying the second permission to the fourth "
- "permission." );
- sp4 = dynamic_cast(sp2->Copy());
- rc = sp4->Equals( sp2 );
- Console::WriteLine( "Is the fourth permission equal to the second "
- "permission? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- Console::WriteLine( "Creating the intersection of the second and "
- "first permissions." );
- sp4 = dynamic_cast(sp2->Intersect( sp1 ));
- Console::WriteLine( "The value of the Flags property is: {0}", sp4->Flags );
-
- //
- //
- Console::WriteLine( "Creating the union of the second and first "
- "permissions." );
- sp4 = dynamic_cast(sp2->Union( sp1 ));
- Console::WriteLine( "Result of the union of the second permission "
- "with the first: {0}", sp4->Flags );
-
- //
- //
- Console::WriteLine( "Using an XML round trip to reset the fourth "
- "permission." );
- sp4->FromXml( sp2->ToXml() );
- rc = sp4->Equals( sp2 );
- Console::WriteLine( "Does the XML round trip result equal the "
- "original permission? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- }
-
-
-public:
-
- // Create a simple byte array containing data to be encrypted.
- static void ProtectData()
- {
- array^secret = {0,1,2,3,4,1,2,3,4};
-
- //Encrypt the data.
- encryptedSecret = Protect( secret );
- Console::WriteLine( "The encrypted byte array is:" );
- if ( encryptedSecret != nullptr )
- PrintValues( encryptedSecret );
- }
-
-
- // Decrypt the data and store in a byte array.
- static void UnprotectData()
- {
- originalData = Unprotect( encryptedSecret );
- if ( originalData != nullptr )
- {
- Console::WriteLine( "\r\nThe original data is:" );
- PrintValues( originalData );
- }
- }
-
-
- // Encrypt data in the specified byte array.
- static array^ Protect( array^data )
- {
- try
- {
-
- // Encrypt the data using DataProtectionScope.CurrentUser.
- // The result can be decrypted only by the user who encrypted
- // the data.
- return ProtectedData::Protect( data, s_additionalEntropy, DataProtectionScope::CurrentUser );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "Data was not encrypted. "
- "An error has occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
- catch ( SecurityException^ e )
- {
- Console::WriteLine( "Insufficient permissions. "
- "An error has occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
-
- }
-
-
- // Decrypt data in the specified byte array.
- static array^ Unprotect( array^data )
- {
- try
- {
-
- //Decrypt the data using DataProtectionScope.CurrentUser.
- return ProtectedData::Unprotect( data, s_additionalEntropy, DataProtectionScope::CurrentUser );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "Data was not decrypted. "
- "An error has occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
- catch ( SecurityException^ e )
- {
- Console::WriteLine( "Insufficient permissions. "
- "An error has occurred." );
- Console::WriteLine( e );
- return nullptr;
- }
-
- }
-
- static void PrintValues( array^myArr )
- {
- System::Collections::IEnumerator^ myEnum = myArr->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- Byte i = safe_cast(myEnum->Current);
- Console::Write( "\t{0}", i );
- }
-
- Console::WriteLine();
- }
-
-};
-
-int main()
-{
- DataProtect::Main();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp
deleted file mode 100644
index 8f6d1b640df..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/fileiopermission.cpp
+++ /dev/null
@@ -1,534 +0,0 @@
-
-// This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml, FromXml,
-// GetPathList and SetPathList methods, and the AllFiles and AllLocalFiles properties
-// of the FileIOPermission class.
-//
-using namespace System::Runtime::InteropServices;
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Collections;
-
-// This class generates FileIOPermission objects.
-
-[assembly:CLSCompliant(true)];
-private ref class FileIOGenerator
-{
-private:
- array^myFile;
- array^myAccess;
- int fileIndex;
-
-public:
- FileIOGenerator()
- {
- array^tempFile = {"C:\\Examples\\Test\\TestFile.txt","C:\\Examples\\Test\\","C:\\Examples\\Test\\..","C:\\Temp"};
- myFile = tempFile;
- array^ tempAccess = {FileIOPermissionAccess::AllAccess,FileIOPermissionAccess::Append,FileIOPermissionAccess::NoAccess,FileIOPermissionAccess::PathDiscovery,FileIOPermissionAccess::Read,FileIOPermissionAccess::Write};
- myAccess = tempAccess;
- ResetIndex();
- }
-
- void ResetIndex()
- {
- fileIndex = 0;
- }
-
-
- // Create a file path.
- //
- bool CreateFilePath( [Out]interior_ptr file )
- {
- if ( fileIndex == myFile->Length )
- {
- *file = "";
- fileIndex++;
- return true;
- }
-
- if ( fileIndex > myFile->Length )
- {
- *file = "";
- return false;
- }
-
- *file = myFile[ fileIndex++ ];
- try
- {
- return true;
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Cannot create FileIOPermission: {0} {1}", *file, e );
- *file = "";
- return true;
- }
-
- }
-
- //
-};
-
-public ref class FileIOPermissionDemo
-{
-private:
-
- // IsSubsetOf determines whether the current permission is a subset of the specified permission.
- // This method compares various FileIOPermission paths with FileIOPermissionAccess set to AllAccess.
- //
- bool IsSubsetOfDemo()
- {
- bool returnValue = true;
- String^ fileIO1;
- String^ fileIO2;
- FileIOPermission^ fileIOPerm1;
- FileIOPermission^ fileIOPerm2;
- FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator;
- FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator;
- fileIOGen1->ResetIndex();
- while ( fileIOGen1->CreateFilePath( &fileIO1 ) )
- {
- if (fileIO1 == "")
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::AllAccess, fileIO1);
-
- Console::WriteLine( "**********************************************************\n" );
- fileIOGen2->ResetIndex();
- while ( fileIOGen2->CreateFilePath( &fileIO2 ) )
- {
- if (fileIO2 == "")
- fileIOPerm2 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm2 = gcnew FileIOPermission(FileIOPermissionAccess::AllAccess, fileIO2);
- String^ firstPermission = fileIO1 == "" || fileIO1 == nullptr ? "null" : fileIO1;
- String^ secondPermission = fileIO2 == "" || fileIO2 == nullptr ? "null" : fileIO2;
- if ( fileIOPerm2 == nullptr )
- continue;
- try
- {
- if ( fileIOPerm1->IsSubsetOf( fileIOPerm2 ) )
- {
- Console::WriteLine( "{0} is a subset of {1}\n", firstPermission, secondPermission );
- }
- else
- {
- Console::WriteLine( "{0} is not a subset of {1}\n", firstPermission, secondPermission );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown for subset :{0}\n{1}\n{2}", (fileIO1->Equals( "" ) ? "null" : fileIO1), (fileIO2->Equals( "" ) ? "null" : fileIO2), e );
- }
-
- }
- }
-
- return returnValue;
- }
-
-
- //
- // Union creates a new permission that is the union of the current permission and the specified permission.
- //
- bool UnionDemo()
- {
- bool returnValue = true;
- String^ fileIO1;
- String^ fileIO2;
- FileIOPermission^ fileIOPerm1;
- FileIOPermission^ fileIOPerm2;
- IPermission^ fileIOPerm3;
- FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator;
- FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator;
- fileIOGen1->ResetIndex();
- while ( fileIOGen1->CreateFilePath( &fileIO1 ) )
- {
- if (fileIO1 == "")
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO1);
-
- Console::WriteLine( "**********************************************************\n" );
- fileIOGen2->ResetIndex();
- while ( fileIOGen2->CreateFilePath( &fileIO2 ) )
- {
- if (fileIO2 == "")
- fileIOPerm2 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm2 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO2);
- try
- {
- if ( fileIOPerm2 == nullptr )
- continue;
- String^ firstPermission = fileIO1 == "" || fileIO1 == nullptr ? "null" : fileIO1;
- String^ secondPermission = fileIO2 == "" || fileIO2 == nullptr ? "null" : fileIO2;
- fileIOPerm3 = dynamic_cast(fileIOPerm1->Union( fileIOPerm2 ));
- fileIOPerm3 = fileIOPerm1->Union( fileIOPerm2 );
- if ( fileIOPerm3 == nullptr )
- {
- Console::WriteLine( "The union of {0} and {1} is null.", firstPermission, secondPermission );
- }
- else
- {
- Console::WriteLine( "The union of {0} and {1} = \n\t{2}", firstPermission, secondPermission, (dynamic_cast(fileIOPerm3))->GetPathList( FileIOPermissionAccess::Read )[ 0 ] );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown for union {0}", e );
- returnValue = false;
- }
-
- }
- }
-
- return returnValue;
- }
-
-
- //
- // Intersect creates and returns a new permission that is the intersection of the current
- // permission and the permission specified.
- //
- bool IntersectDemo()
- {
- bool returnValue = true;
- String^ fileIO1;
- String^ fileIO2;
- FileIOPermission^ fileIOPerm1;
- FileIOPermission^ fileIOPerm2;
- FileIOPermission^ fileIOPerm3;
- FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator;
- FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator;
- fileIOGen1->ResetIndex();
- while ( fileIOGen1->CreateFilePath ( &fileIO1 ) )
- {
- if (fileIO1 == "")
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO1);
-
- Console::WriteLine( "**********************************************************\n" );
- fileIOGen2->ResetIndex();
- while ( fileIOGen2->CreateFilePath( &fileIO2 ) )
- {
- if (fileIO2 == "")
- fileIOPerm2 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm2 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO2);
- String^ firstPermission = fileIO1 == "" || fileIO1 == nullptr ? "null" : fileIO1;
- String^ secondPermission = fileIO2 == "" || fileIO2 == nullptr ? "null" : fileIO2;
- try
- {
- fileIOPerm3 = dynamic_cast(fileIOPerm1->Intersect( fileIOPerm2 ));
- if ( fileIOPerm3 != nullptr && fileIOPerm3->GetPathList( FileIOPermissionAccess::Read ) != nullptr )
- {
- Console::WriteLine( "The intersection of {0} and \n\t{1} = \n\t{2}", firstPermission, secondPermission, (dynamic_cast(fileIOPerm3))->GetPathList( FileIOPermissionAccess::Read )[ 0 ] );
- }
- else
- {
- Console::WriteLine( "The intersection of {0} and {1} is null.", firstPermission, secondPermission );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown for intersection {0}", e );
- returnValue = false;
- }
-
- }
- }
-
- return returnValue;
- }
-
-
- //
- //Copy creates and returns an identical copy of the current permission.
- //
- bool CopyDemo()
- {
- bool returnValue = true;
- String^ fileIO1;
- FileIOPermission^ fileIOPerm1;
- FileIOPermission^ fileIOPerm2;
- FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator;
- FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator;
- fileIOGen1->ResetIndex();
- while ( fileIOGen1->CreateFilePath( &fileIO1 ) )
- {
- if (fileIO1 == "")
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO1);
-
- Console::WriteLine( "**********************************************************\n" );
- fileIOGen2->ResetIndex();
- try
- {
- fileIOPerm2 = dynamic_cast(fileIOPerm1->Copy());
- if ( fileIOPerm2 != nullptr )
- {
- Console::WriteLine( "Result of copy = {0}\n", fileIOPerm2 );
- }
- else
- {
- Console::WriteLine( "Result of copy is null. \n" );
- }
- }
- catch ( Exception^ e )
- {
- {
- if ( fileIO1->Equals( "" ) )
- {
- Console::WriteLine( "The target FileIOPermission is empty, copy failed." );
- }
- else
- Console::WriteLine( e );
- }
- continue;
- }
-
- }
-
- return returnValue;
- }
-
-
- //
- // ToXml creates an XML encoding of the permission and its current state;
- // FromXml reconstructs a permission with the specified state from the XML encoding.
- //
- bool ToFromXmlDemo()
- {
- bool returnValue = true;
- String^ fileIO1;
- FileIOPermission^ fileIOPerm1;
- FileIOPermission^ fileIOPerm2;
- FileIOGenerator^ fileIOGen1 = gcnew FileIOGenerator;
- FileIOGenerator^ fileIOGen2 = gcnew FileIOGenerator;
- fileIOGen1->ResetIndex();
- while ( fileIOGen1->CreateFilePath( &fileIO1 ) )
- {
- if (fileIO1 == "")
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::None);
- else
- fileIOPerm1 = gcnew FileIOPermission(FileIOPermissionAccess::Read, fileIO1);
-
- Console::WriteLine( "********************************************************\n" );
- fileIOGen2->ResetIndex();
- try
- {
- fileIOPerm2 = gcnew FileIOPermission( PermissionState::None );
- fileIOPerm2->FromXml( fileIOPerm1->ToXml() );
- Console::WriteLine( "Result of ToFromXml = {0}\n", fileIOPerm2 );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "ToFromXml failed :{0}{1}", fileIOPerm1, e );
- continue;
- }
-
- }
-
- return returnValue;
- }
-
-
- //
- // AddPathList adds access for the specified files and directories to the existing state of the permission.
- // SetPathList sets the specified access to the specified files and directories, replacing the existing state
- // of the permission.
- // GetPathList gets all files and directories that have the specified FileIOPermissionAccess.
- //
- bool SetGetPathListDemo()
- {
- try
- {
- Console::WriteLine( "********************************************************\n" );
- FileIOPermission^ fileIOPerm1;
- Console::WriteLine( "Creating a FileIOPermission with AllAccess rights for 'C:\\Examples\\Test\\TestFile.txt" );
-
- //
- fileIOPerm1 = gcnew FileIOPermission( FileIOPermissionAccess::AllAccess,"C:\\Examples\\Test\\TestFile.txt" );
-
- //
- Console::WriteLine( "Adding 'C:\\Temp' to the write access list, and \n 'C:\\Examples\\Test' to read access." );
- fileIOPerm1->AddPathList( FileIOPermissionAccess::Write, "C:\\Temp" );
- fileIOPerm1->AddPathList( FileIOPermissionAccess::Read, "C:\\Examples\\Test" );
- array^paths = fileIOPerm1->GetPathList( FileIOPermissionAccess::Read );
- Console::WriteLine( "Read access before SetPathList = " );
- IEnumerator^ myEnum = paths->GetEnumerator();
- while ( myEnum->MoveNext() )
- {
- String^ path = safe_cast(myEnum->Current);
- Console::WriteLine( "\t{0}", path );
- }
-
- Console::WriteLine( "Setting the read access list to \n'C:\\Temp'" );
- fileIOPerm1->SetPathList( FileIOPermissionAccess::Read, "C:\\Temp" );
- paths = fileIOPerm1->GetPathList( FileIOPermissionAccess::Read );
- Console::WriteLine( "Read access list after SetPathList = " );
- IEnumerator^ myEnum1 = paths->GetEnumerator();
- while ( myEnum1->MoveNext() )
- {
- String^ path = safe_cast(myEnum1->Current);
- Console::WriteLine( "\t{0}", path );
- }
-
- paths = fileIOPerm1->GetPathList( FileIOPermissionAccess::Write );
- Console::WriteLine( "Write access list after SetPathList = " );
- IEnumerator^ myEnum2 = paths->GetEnumerator();
- while ( myEnum2->MoveNext() )
- {
- String^ path = safe_cast(myEnum2->Current);
- Console::WriteLine( "\t{0}", path );
- }
-
- Console::WriteLine( "Write access = \n{0}", fileIOPerm1->GetPathList( FileIOPermissionAccess::AllAccess ) );
- }
- catch ( ArgumentException^ e )
- {
-
- // FileIOPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
- Console::WriteLine( "An ArgumentException occurred as a result of using AllAccess. This property cannot be used as a parameter in GetPathList because it represents more than one type of file variable access. : \n{0}", e );
- }
-
- return true;
- }
-
-
- //
- // The AllFiles property gets or sets the permitted access to all files.
- // The AllLocalFiles property gets or sets the permitted access to all local files.
- //
- bool AllFilesDemo()
- {
- try
- {
- Console::WriteLine( "********************************************************\n" );
- FileIOPermission^ fileIOPerm1;
- Console::WriteLine( "Creating a FileIOPermission and adding read access for all files" );
- fileIOPerm1 = gcnew FileIOPermission( FileIOPermissionAccess::AllAccess,"C:\\Examples\\Test\\TestFile.txt" );
- fileIOPerm1->AllFiles = FileIOPermissionAccess::Read;
- Console::WriteLine( "AllFiles access = {0}", fileIOPerm1->AllFiles );
- Console::WriteLine( "Adding AllAccess rights for local files." );
- fileIOPerm1->AllLocalFiles = FileIOPermissionAccess::AllAccess;
- Console::WriteLine( "AllLocalFiles access = {0}", fileIOPerm1->AllLocalFiles );
- }
- catch ( ArgumentException^ e )
- {
- Console::WriteLine( e );
- return false;
- }
-
- return true;
- }
-
-
-public:
-
- //
- // Invoke all demos.
- bool RunDemo()
- {
- bool ret = true;
- bool retTmp;
-
- // Call the IsSubsetOfPath demo.
- if ( retTmp = IsSubsetOfDemo() )
- Console::WriteLine( "IsSubsetOf demo completed successfully." );
- else
- Console::WriteLine( "IsSubsetOf demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Union demo.
- if ( retTmp = UnionDemo() )
- Console::WriteLine( "Union demo completed successfully." );
- else
- Console::WriteLine( "Union demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Intersect demo.
- if ( retTmp = IntersectDemo() )
- Console::WriteLine( "Intersect demo completed successfully." );
- else
- Console::WriteLine( "Intersect demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Copy demo.
- if ( retTmp = CopyDemo() )
- Console::WriteLine( "Copy demo completed successfully." );
- else
- Console::WriteLine( "Copy demo failed." );
-
- ret = retTmp && ret;
-
- // Call the ToFromXml demo.
- if ( retTmp = ToFromXmlDemo() )
- Console::WriteLine( "ToFromXml demo completed successfully." );
- else
- Console::WriteLine( "ToFromXml demo failed." );
-
- ret = retTmp && ret;
-
- // Call the SetGetPathList demo.
- if ( retTmp = SetGetPathListDemo() )
- Console::WriteLine( "SetGetPathList demo completed successfully." );
- else
- Console::WriteLine( "SetGetPathList demo failed." );
-
- ret = retTmp && ret;
-
- // Call the AllFiles demo.
- if ( retTmp = AllFilesDemo() )
- Console::WriteLine( "AllFiles demo completed successfully." );
- else
- Console::WriteLine( "AllFiles demo failed." );
-
- ret = retTmp && ret;
- return (ret);
- }
-
-};
-
-
-// Test harness.
-int main()
-{
- try
- {
- FileIOPermissionDemo^ democase = gcnew FileIOPermissionDemo;
- bool ret = democase->RunDemo();
- if ( ret )
- {
- Console::WriteLine( "FileIOPermission demo completed successfully." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 100;
- }
- else
- {
- Console::WriteLine( "FileIOPermission demo failed." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "FileIOPermission demo failed" );
- Console::WriteLine( e );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
-
-}
-
-//
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
deleted file mode 100644
index 6593317f496..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/CPP/remarks.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-
-int main()
-{
- try
- {
- FileIOPermission^ fileIOPerm1;
- fileIOPerm1 = gcnew FileIOPermission(PermissionState::Unrestricted);
-
- // Tests for: SetPathList(FileIOPermissionAccess,String)
-
- // Test the Read list
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, "C:\\documents");
-
- Console::WriteLine("Read access before SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read))
- {
- Console::WriteLine("\t" + path);
- }
-
- //
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, "C:\\temp");
- //
-
- Console::WriteLine("Read access after SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read))
- {
- Console::WriteLine("\t" + path);
- }
-
- // Test the Write list
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, "C:\\temp");
-
- Console::WriteLine("Write access before SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write))
- {
- Console::WriteLine("\t" + path);
- }
- //
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, "C:\\documents");
- //
-
- Console::WriteLine("Write access after SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write))
- {
- Console::WriteLine("\t" + path);
- }
-
- // Tests for: SetPathList(FileIOPermissionAccess,String[])
-
- // Test the Read list
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, gcnew array {"C:\\pictures", "C:\\music"});
-
- Console::WriteLine("Read access before SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read))
- {
- Console::WriteLine("\t" + path);
- }
-
- //
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Read, gcnew array {"C:\\temp", "C:\\Documents"});
- //
-
- Console::WriteLine("Read access after SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Read))
- {
- Console::WriteLine("\t" + path);
- }
-
- // Test the Write list
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, gcnew array {"C:\\temp", "C:\\Documents"});
-
- Console::WriteLine("Write access before SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write))
- {
- Console::WriteLine("\t" + path);
- }
- //
- fileIOPerm1->SetPathList(FileIOPermissionAccess::Write, gcnew array {"C:\\pictures", "C:\\music"});
- //
-
- Console::WriteLine("Write access after SetPathList = ");
- for each (String^ path in fileIOPerm1->GetPathList(FileIOPermissionAccess::Write))
- {
- Console::WriteLine("\t" + path);
- }
- }
- catch (Exception^ ex)
- {
- Console::WriteLine(ex->Message);
- }
-}
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp
deleted file mode 100644
index da97ffa6c9f..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/CPP/fileiopermissionattribute.cpp
+++ /dev/null
@@ -1,102 +0,0 @@
-
-//
-// This sample demonstrates the use of the FileIOPermissionAttribute class.
-// The sample follows the recommended procedure of first granting PermitOnly permissions,
-// then using a Deny on that set of granted permissions.
-using namespace System;
-using namespace System::Reflection;
-using namespace System::Security::Permissions;
-using namespace System::Security;
-using namespace System::IO;
-void PermitOnlyMethod();
-void PermitOnlyTestMethod();
-void TestFailed();
-
-
-// This method demonstrates the use of the FileIOPermissionAttribute to create a PermitOnly permission.
-//
-//
-// Set the Read property.
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,Read="C:\\")]
-//
-//
-// Set the PathDiscovery property.
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,
-PathDiscovery="C:\\Documents and Settings\\All Users")]
-//
-//
-// Set the Append property.
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,
-Append="C:\\Documents and Settings\\All Users\\Application Data")]
-//
-//
-// Set the Write property.
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,
-Write="C:\\Documents and Settings\\All Users\\Application Data\\Microsoft")]
-//
-//
-// Set the All property.
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,
-All="C:\\Documents and Settings\\All Users\\Application Data\\Microsoft\\Network")]
-//
-
-void PermitOnlyMethod()
-{
- Console::WriteLine( "Executing PermitOnlyMethod." );
- Console::WriteLine( "PermitOnly the Read permission for drive C." );
- Console::WriteLine( "PermitOnly the PathDiscovery permission for \n\tC:\\Documents and Settings\\All Users." );
- Console::WriteLine( "PermitOnly the Append permission for \n\tC:\\Documents and Settings\\All Users\\Application Data." );
- Console::WriteLine( "PermitOnly the Write permission for \n\tC:\\Documents and Settings\\All Users\\Application Data\\Microsoft." );
- Console::WriteLine( "PermitOnly the All permission for \n\tC:\\Documents and Settings\\All Users\\Application Data\\Microsoft\\Network." );
- PermitOnlyTestMethod();
-}
-//
-
-void PermitOnlyTestMethod()
-{
- Console::WriteLine("Executing PermitOnlyTestMethod.");
- try
- {
- PermissionSet^ ps = gcnew PermissionSet(PermissionState::None);
- ps->AddPermission(gcnew FileIOPermission(FileIOPermissionAccess::Write,
- "C:\\Documents and Settings\\All Users\\Application Data\\Microsoft\\Network\\SomeFile"));
- Console::WriteLine("Demanding permission to write " +
- "'C:\\Documents and Settings\\All Users\\Application Data\\Microsoft\\Network\\SomeFile'");
- ps->Demand();
- Console::WriteLine("Demand succeeded.");
- ps->AddPermission(
- gcnew FileIOPermission(FileIOPermissionAccess::Write,
- "C:\\"));
- Console::WriteLine("Demanding permission to write to drive C.");
-
- // This demand should cause an exception.
- ps->Demand();
- // The TestFailed method is called if an exception is not thrown.
- TestFailed();
- }
- catch (Exception^ e)
- {
- Console::WriteLine("An exception was thrown because of a write demand: " + e->Message);
- }
-}
-
-void TestFailed()
-{
- Console::WriteLine( "Executing TestFailed." );
- Console::WriteLine( "Throwing an exception." );
- throw gcnew Exception;
-}
-
-int main()
-{
- try
- {
- PermitOnlyMethod();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp
deleted file mode 100644
index 0f1fb73c3e7..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/CPP/gacidentitypermission.cpp
+++ /dev/null
@@ -1,260 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-public ref class GacIdentityPermissionDemo
-{
-private:
-
- //
- // IsSubsetOf determines whether the current permission is a subset of the specified permission.
- bool IsSubsetOfDemo()
- {
- try
- {
-
- //
- GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
- GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission( PermissionState::None );
- if ( Gac1->Equals( Gac2 ) )
- Console::WriteLine( "GacIdentityPermission() equals GacIdentityPermission(PermissionState.None)." );
-
-
- //
- if ( Gac1->IsSubsetOf( Gac2 ) )
- {
- Console::WriteLine( "{0} is a subset of {1}", Gac1, Gac2 );
- }
- else
- {
- Console::WriteLine( "{0} is not a subset of {1}", Gac1, Gac2 );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown : {0}", e );
- return false;
- }
-
- return true;
- }
-
-
- //
- //
- // Union creates a new permission that is the union of the current permission
- // and the specified permission.
- bool UnionDemo()
- {
-
- //
- GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission( PermissionState::None );
-
- //
- //
- GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
-
- //
- try
- {
- GacIdentityPermission ^ p3 = dynamic_cast(Gac1->Union( Gac2 ));
- if ( p3 != nullptr )
- {
- Console::WriteLine( "The union of two GacIdentityPermissions was successful." );
- }
- else
- {
- Console::WriteLine( "The union of two GacIdentityPermissions failed." );
- return false;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown : {0}", e );
- return false;
- }
-
- return true;
- }
-
-
- //
- //
- // Intersect creates and returns a new permission that is the intersection of the
- // current permission and the specified permission.
- bool IntersectDemo()
- {
- GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
- GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
- try
- {
- GacIdentityPermission ^ p3 = dynamic_cast(Gac1->Intersect( Gac2 ));
- if ( p3 != nullptr )
- {
- Console::WriteLine( "The intersection of the two permissions = {0}\n", p3 );
- }
- else
- {
- Console::WriteLine( "The intersection of the two permissions is null.\n" );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "An exception was thrown : {0}", e );
- return false;
- }
-
- return true;
- }
-
-
- //
- //
- //Copy creates and returns an identical copy of the current permission.
- bool CopyDemo()
- {
- GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
- GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
- Console::WriteLine( "**************************************************************************" );
- try
- {
- Gac2 = dynamic_cast(Gac1->Copy());
- if ( Gac2 != nullptr )
- {
- Console::WriteLine( "Result of copy = {0}\n", Gac2 );
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Copy failed : {0}{1}", Gac1, e );
- return false;
- }
-
- return true;
- }
-
-
- //
- //
- // ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
- // permission with the specified state from the XML encoding.
- bool ToFromXmlDemo()
- {
- GacIdentityPermission ^ Gac1 = gcnew GacIdentityPermission;
- GacIdentityPermission ^ Gac2 = gcnew GacIdentityPermission;
- Console::WriteLine( "**************************************************************************" );
- try
- {
- Gac2 = gcnew GacIdentityPermission( PermissionState::None );
- Gac2->FromXml( Gac1->ToXml() );
- bool result = Gac2->Equals( Gac1 );
- if ( Gac2->IsSubsetOf( Gac1 ) && Gac1->IsSubsetOf( Gac2 ) )
- {
- Console::WriteLine( "Result of ToFromXml = {0}", Gac2 );
- }
- else
- {
- Console::WriteLine( Gac2 );
- Console::WriteLine( Gac1 );
- return false;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "ToFromXml failed. {0}", e );
- return false;
- }
-
- return true;
- }
-
-
-public:
-
- //
- // Invoke all demos.
- bool RunDemo()
- {
- bool returnCode = true;
- bool tempReturnCode;
-
- // Call the IsSubsetOf demo.
- if ( tempReturnCode = IsSubsetOfDemo() )
- Console::WriteLine( "IsSubsetOf demo completed successfully." );
- else
- Console::WriteLine( "Subset demo failed." );
-
- returnCode = tempReturnCode && returnCode;
-
- // Call the Union demo.
- if ( tempReturnCode = UnionDemo() )
- Console::WriteLine( "Union demo completed successfully." );
- else
- Console::WriteLine( "Union demo failed." );
-
- returnCode = tempReturnCode && returnCode;
-
- // Call the Intersect demo.
- if ( tempReturnCode = IntersectDemo() )
- Console::WriteLine( "Intersect demo completed successfully." );
- else
- Console::WriteLine( "Intersect demo failed." );
-
- returnCode = tempReturnCode && returnCode;
-
- // Call the Copy demo.
- if ( tempReturnCode = CopyDemo() )
- Console::WriteLine( "Copy demo completed successfully." );
- else
- Console::WriteLine( "Copy demo failed." );
-
- returnCode = tempReturnCode && returnCode;
-
- // Call the ToFromXML demo.
- if ( tempReturnCode = ToFromXmlDemo() )
- Console::WriteLine( "ToFromXML demo completed successfully." );
- else
- Console::WriteLine( "ToFromXml demo failed." );
-
- returnCode = tempReturnCode && returnCode;
- return (returnCode);
- }
-
-};
-
-
-// Test harness.
-int main()
-{
- try
- {
- GacIdentityPermissionDemo^ testcase = gcnew GacIdentityPermissionDemo;
- bool returnCode = testcase->RunDemo();
- if ( returnCode )
- {
- Console::WriteLine( "The GacIdentityPermission demo completed successfully." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 100;
- }
- else
- {
- Console::WriteLine( "The GacIdentityPermission demo failed." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "The GacIdentityPermission demo failed." );
- Console::WriteLine( e );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
-
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp
deleted file mode 100644
index 19d961987aa..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/CPP/gacidentitypermissionattribute.cpp
+++ /dev/null
@@ -1,51 +0,0 @@
-
-//
-// To run this sample you must create a strong-name key named snkey.snk
-// using the Strong Name tool (sn.exe). Both the library assembly and the
-// application assembly that calls it must be signed with that key.
-// To run successfully, the application assembly must be in the global
-// assembly cache.
-// This console application can be created using the following code.
-
-//#using
-//#using
-//using namespace System;
-//using namespace System::Security;
-//using namespace System::Reflection;
-//using namespace ClassLibrary1;
-//[assembly: AssemblyVersion(S"1.0.555.0")]
-//[assembly: AssemblyKeyFile(S"snKey.snk")];
-//int main()
-//{
-// try
-// {
-// Class1* myLib = new Class1();
-// myLib->DoNothing();
-//
-// Console::WriteLine(S"Exiting the sample.");
-// }
-// catch (Exception* e)
-// {
-// Console::WriteLine(e->Message);
-// }
-//}
-using namespace System;
-using namespace System::Security::Permissions;
-
-namespace ClassLibrary1
-{
- //
- // Demand that the calling program be in the global assembly cache.
- [GacIdentityPermissionAttribute(SecurityAction::Demand)]
- public ref class Class1
- //
- {
- public:
- void DoNothing()
- {
- Console::WriteLine( "Exiting the library program." );
- }
- };
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp
deleted file mode 100644
index 6d805d4667a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/CPP/hostprotectionattribute.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-
-
-//
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::IO;
-using namespace System::Threading;
-using namespace System::Security;
-using namespace System::Security::Policy;
-using namespace System::Security::Principal;
-using namespace System::Security::Permissions;
-using namespace System::Diagnostics;
-using namespace System::ComponentModel;
-using namespace System::Windows::Forms;
-using namespace System::Security::Permissions;
-
-//
-// The following class is an example of code that exposes external process management.
-// Add the LicenseProviderAttribute to the control.
-
-[LicenseProvider(LicFileLicenseProvider::typeid)]
-public ref class MyControl: public System::Windows::Forms::Control
-{
-private:
-
- // Create a new, null license.
- License^ license;
-
-public:
- [HostProtection(ExternalProcessMgmt=true)]
- MyControl()
- {
- license = nullptr;
-
- // Determine if a valid license can be granted.
- bool isValid = LicenseManager::IsValid( MyControl::typeid );
- Console::WriteLine( "The result of the IsValid method call is {0}", isValid );
- }
-
-};
-//
-
-// If this application is run on a server that implements host protection, the HostProtection attribute
-// is applied. If the application is run on a server that is not host-protected, the attribute
-// evaporates; it is not detected and therefore not applied. HostProtection can be configured with
-// members of the HostProtectionResource enumeration to customize the protection offered.
-// The primary intent of this sample is to show situations in which the HostProtection attribute
-// might be meaningfully used. The environment required to demonstrate a particular HostProtection is
-// too complex to invoke within the scope of this sample.
-public ref class HostProtectionExample
-{
-public:
- static int Success = 100;
-
-private:
-
- //
- // Use the enumeration flags to indicate that this method exposes shared state and
- // self-affecting process management.
- // Either of the following attribute statements can be used to set the
- // resource flags.
- // Exit the sample when an exception is thrown.
-
- [HostProtection(SharedState=true,SelfAffectingProcessMgmt=true)]
- [HostProtection(Resources=HostProtectionResource::SharedState|
- HostProtectionResource::SelfAffectingProcessMgmt)]
- static void Exit( String^ Message, int Code )
- {
- Console::WriteLine( "\nFAILED: {0} {1}", Message, Code );
- Environment::ExitCode = Code;
- Environment::Exit( Code );
- }
- //
-
- //
- // Use the enumeration flags to indicate that this method exposes shared state,
- // self-affecting process management, and self-affecting threading.
- // This method allows the user to quit the sample.
-
- [HostProtection(SharedState=true,SelfAffectingProcessMgmt=true,
- SelfAffectingThreading=true,UI=true)]
- static void ExecuteBreak()
- {
- Console::WriteLine( "Executing Debugger.Break." );
- Debugger::Break();
- Debugger::Log( 1, "info", "test message" );
- }
- //
-
- //
- // Use the enumeration flags to indicate that this method exposes shared state,
- // self-affecting threading and the security infrastructure.
- // ApplyIdentity sets the current identity.
-
- [HostProtection(SharedState=true,SelfAffectingThreading=true,
- SecurityInfrastructure=true)]
- static int ApplyIdentity()
- {
- array^roles = {"User"};
- try
- {
- AppDomain^ mAD = AppDomain::CurrentDomain;
- GenericPrincipal^ mGenPr = gcnew GenericPrincipal( WindowsIdentity::GetCurrent(),roles );
- mAD->SetPrincipalPolicy( PrincipalPolicy::WindowsPrincipal );
- mAD->SetThreadPrincipal( mGenPr );
- return Success;
- }
- catch ( Exception^ e )
- {
- Exit( e->ToString(), 5 );
- }
-
- return 0;
- }
- //
-
-public:
-
- // The following method is started on a separate thread.
- [PermissionSet(SecurityAction::Demand, Name="FullTrust")]
- static void WatchFileEvents()
- {
- try
- {
- Console::WriteLine( "In the child thread." );
- FileSystemWatcher^ watcher = gcnew FileSystemWatcher;
- watcher->Path = "C:\\Temp";
-
- // Watch for changes in LastAccess and LastWrite times, and
- // name changes to files or directories.
- watcher->NotifyFilter = static_cast(NotifyFilters::LastAccess | NotifyFilters::LastWrite | NotifyFilters::FileName | NotifyFilters::DirectoryName);
-
- // Watch only text files.
- watcher->Filter = "*.txt";
-
- // Add event handlers.
- watcher->Changed += gcnew FileSystemEventHandler( OnChanged );
- watcher->Created += gcnew FileSystemEventHandler( OnChanged );
- watcher->Deleted += gcnew FileSystemEventHandler( OnChanged );
-
- // Begin watching.
- watcher->EnableRaisingEvents = true;
-
- // Wait for the user to quit the program.
- Console::WriteLine( "Event handlers have been enabled." );
- while ( Console::Read() != 'q' )
- ;
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- }
-
-
-private:
-
- //
- // Use the enumeration flags to indicate that this method exposes synchronization
- // and external threading.
-
- [HostProtection(Synchronization=true,ExternalThreading=true)]
- static void StartThread()
- {
- Thread^ t = gcnew Thread( gcnew ThreadStart( WatchFileEvents ) );
-
- // Start the new thread. On a uniprocessor, the thread is not given
- // any processor time until the main thread yields the processor.
- t->Start();
-
- // Give the new thread a chance to execute.
- Thread::Sleep( 1000 );
- }
- //
-
-public:
-
- // Call methods that show the use of the HostProtectionResource enumeration.
- [HostProtection(Resources=HostProtectionResource::All)]
- static int Main()
- {
- try
- {
-
- // Show use of the HostProtectionResource.SharedState,
- // HostProtectionResource.SelfAffectingThreading, and
- // HostProtectionResource.Security enumeration values.
- ApplyIdentity();
- Directory::CreateDirectory( "C:\\Temp" );
-
- // Show use of the HostProtectionResource.Synchronization and
- // HostProtectionResource.ExternalThreading enumeration values.
- StartThread();
- Console::WriteLine( "In the main thread." );
- Console::WriteLine( "Deleting and creating 'MyTestFile.txt'." );
- if ( File::Exists( "C:\\Temp\\MyTestFile.txt" ) )
- {
- File::Delete( "C:\\Temp\\MyTestFile.txt" );
- }
- StreamWriter^ sr = File::CreateText( "C:\\Temp\\MyTestFile.txt" );
- sr->WriteLine( "This is my file." );
- sr->Close();
- Thread::Sleep( 1000 );
-
- // Show use of the HostProtectionResource.SharedState,
- // HostProtectionResource.SelfProcessMgmt,
- // HostProtectionResource.SelfAffectingThreading, and
- // HostProtectionResource.UI enumeration values.
- ExecuteBreak();
-
- // Show the use of the HostProtectionResource.ExternalProcessManagement enumeration value.
- MyControl^ myControl = gcnew MyControl;
- Console::WriteLine( "Enter 'q' to quit the sample." );
- return 100;
- }
- catch ( Exception^ e )
- {
- Exit( e->ToString(), 0 );
- return 0;
- }
- }
-
- // Define the event handlers.
- private:
- static void OnChanged( Object^ /*source*/, FileSystemEventArgs^ e )
- {
-
- // Specify whether a file is changed, created, or deleted.
- Console::WriteLine( "In the OnChanged event handler." );
- Console::WriteLine( "File: {0} {1}", e->FullPath, e->ChangeType );
- }
-
-};
-
-int main()
-{
- return HostProtectionExample::Main();
-}
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp
deleted file mode 100644
index ac08770304c..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/CPP/keycontainerpermission.cpp
+++ /dev/null
@@ -1,296 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Cryptography;
-
-public ref class KeyContainerPermissionDemo
-{
-private:
- static CspParameters^ cspParams = gcnew CspParameters;
- static RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider;
- static String^ providerName;
- static int providerType;
- static String^ myKeyContainerName;
-
- // Create three KeyContainerPermissionAccessEntry objects, each with a different constructor.
- //
- static KeyContainerPermissionAccessEntry^ keyContainerPermAccEntry1 = gcnew KeyContainerPermissionAccessEntry( "MyKeyContainer",KeyContainerPermissionFlags::Create );
-
- //
- //
- static KeyContainerPermissionAccessEntry^ keyContainerPermAccEntry2 = gcnew KeyContainerPermissionAccessEntry( cspParams,KeyContainerPermissionFlags::Open );
-
- //
- //
- static KeyContainerPermissionAccessEntry^ keyContainerPermAccEntry3 = gcnew KeyContainerPermissionAccessEntry( "Machine",providerName,providerType,myKeyContainerName,1,KeyContainerPermissionFlags::Open );
-
-public:
-
- //
- static int Main()
- {
- try
- {
-
- // Create a key container for use in the sample.
- GenKey_SaveInContainer( "MyKeyContainer" );
-
- // Initialize property values for creating a KeyContainerPermissionAccessEntry object.
- myKeyContainerName = rsa->CspKeyContainerInfo->KeyContainerName;
- providerName = rsa->CspKeyContainerInfo->ProviderName;
- providerType = rsa->CspKeyContainerInfo->ProviderType;
- cspParams->KeyContainerName = myKeyContainerName;
- cspParams->ProviderName = providerName;
- cspParams->ProviderType = providerType;
-
- // Display the KeyContainerPermissionAccessEntry properties using
- // the third KeyContainerPermissionAccessEntry object.
- DisplayAccessEntryMembers();
-
- //
- // Add access entry objects to a key container permission.
- KeyContainerPermission ^ keyContainerPerm1 = gcnew KeyContainerPermission( PermissionState::Unrestricted );
- Console::WriteLine( "Is the permission unrestricted? {0}", keyContainerPerm1->IsUnrestricted() );
- keyContainerPerm1->AccessEntries->Add( keyContainerPermAccEntry1 );
- keyContainerPerm1->AccessEntries->Add( keyContainerPermAccEntry2 );
-
- //
- // Display the permission.
- System::Console::WriteLine( keyContainerPerm1->ToXml() );
-
- //
- // Create an array of KeyContainerPermissionAccessEntry objects
- array^keyContainerPermAccEntryArray = {keyContainerPermAccEntry1,keyContainerPermAccEntry2};
-
- // Create a new KeyContainerPermission using the array.
- KeyContainerPermission ^ keyContainerPerm2 = gcnew KeyContainerPermission( KeyContainerPermissionFlags::AllFlags,keyContainerPermAccEntryArray );
-
- //
- DisplayPermissionMembers( keyContainerPerm2, keyContainerPermAccEntryArray );
-
- // Demonstrate the effect of a deny for opening a key container.
- DenyOpen();
-
- // Demonstrate the deletion of a key container.
- DeleteContainer();
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadKey();
- return 0;
-
- // Close the current try block that did not expect an exception.
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Unexpected exception thrown: {0}", e->Message );
- return 0;
- }
-
- }
-
-
-private:
- static void DisplayAccessEntryMembers()
- {
-
- //
- Console::WriteLine( "\nKeycontainerName is {0}", keyContainerPermAccEntry3->KeyContainerName );
-
- //
- //
- Console::WriteLine( "KeySpec is {0}", (1 == keyContainerPermAccEntry3->KeySpec ? "AT_KEYEXCHANGE " : "AT_SIGNATURE") );
-
- //
- //
- Console::WriteLine( "KeyStore is {0}", keyContainerPermAccEntry3->KeyStore );
-
- //
- //
- Console::WriteLine( "ProviderName is {0}", keyContainerPermAccEntry3->ProviderName );
-
- //
- //
- Console::WriteLine( "ProviderType is {0}", (1 == keyContainerPermAccEntry3->ProviderType ? "PROV_RSA_FULL" : keyContainerPermAccEntry3->ProviderType.ToString()) );
-
- //
- //
- Console::WriteLine( "Hashcode = {0}", keyContainerPermAccEntry3->GetHashCode() );
-
- //
- //
- Console::WriteLine( "Are the KeyContainerPermissionAccessEntry objects equal? {0}", keyContainerPermAccEntry3->Equals( keyContainerPermAccEntry2 ) );
-
- //
- }
-
- static void DisplayPermissionMembers( KeyContainerPermission ^ keyContainerPerm2, array^keyContainerPermAccEntryArray )
- {
-
- // Display the KeyContainerPermission properties.
- //
- Console::WriteLine( "\nFlags value is {0}", keyContainerPerm2->Flags );
-
- //
- //
- KeyContainerPermission ^ keyContainerPerm3 = dynamic_cast(keyContainerPerm2->Copy());
- Console::WriteLine( "Is the copy equal to the original? {0}", keyContainerPerm3->Equals( keyContainerPerm2 ) );
-
- //
- //
- // Perform an XML roundtrip.
- keyContainerPerm3->FromXml( keyContainerPerm2->ToXml() );
- Console::WriteLine( "Was the XML roundtrip successful? {0}", keyContainerPerm3->Equals( keyContainerPerm2 ) );
-
- //
- KeyContainerPermission ^ keyContainerPerm4 = gcnew KeyContainerPermission( KeyContainerPermissionFlags::Open,keyContainerPermAccEntryArray );
-
- //
- KeyContainerPermission ^ keyContainerPerm5 = dynamic_cast(keyContainerPerm2->Intersect( keyContainerPerm4 ));
- Console::WriteLine( "Flags value after the intersection is {0}", keyContainerPerm5->Flags );
-
- //
- //
- keyContainerPerm5 = dynamic_cast(keyContainerPerm2->Union( keyContainerPerm4 ));
-
- //
- //
- Console::WriteLine( "Flags value after the union is {0}", keyContainerPerm5->Flags );
-
- //
- //
- Console::WriteLine( "Is one permission a subset of the other? {0}", keyContainerPerm4->IsSubsetOf( keyContainerPerm2 ) );
-
- //
- }
-
- static void GenKey_SaveInContainer( String^ containerName )
- {
-
- // Create the CspParameters object and set the key container
- // name used to store the RSA key pair.
- cspParams = gcnew CspParameters;
- cspParams->KeyContainerName = containerName;
-
- // Create a new instance of RSACryptoServiceProvider that accesses
- // the key container identified by the containerName parameter.
- rsa = gcnew RSACryptoServiceProvider( cspParams );
-
- // Display the key information to the console.
- Console::WriteLine( "\nKey added to container: \n {0}", rsa->ToXmlString( true ) );
- }
-
- static void GetKeyFromContainer( String^ containerName )
- {
- try
- {
- cspParams = gcnew CspParameters;
- cspParams->KeyContainerName = containerName;
-
- // Create a new instance of RSACryptoServiceProvider that accesses
- // the key container identified by the containerName parameter.
- // If the key container does not exist, a new one is created.
- rsa = gcnew RSACryptoServiceProvider( cspParams );
-
- // Use the rsa object to access the key.
- // Display the key information to the console.
- Console::WriteLine( "\nKey retrieved from container : \n {0}", rsa->ToXmlString( true ) );
- Console::WriteLine( "KeycontainerName is {0}", rsa->CspKeyContainerInfo->KeyContainerName );
- Console::WriteLine( "ProviderName is {0}", rsa->CspKeyContainerInfo->ProviderName );
- Console::WriteLine( "ProviderType is {0}", (1 == rsa->CspKeyContainerInfo->ProviderType ? "PROV_RSA_FULL" : rsa->CspKeyContainerInfo->ProviderType.ToString()) );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Exception thrown: {0}", e->Message );
- }
-
- }
-
- static void DeleteKeyContainer( String^ containerName )
- {
-
- // Create the CspParameters object and set the key container
- // name used to store the RSA key pair.
- cspParams = gcnew CspParameters;
- cspParams->KeyContainerName = containerName;
-
- // Create a new instance of RSACryptoServiceProvider that accesses
- // the key container.
- rsa = gcnew RSACryptoServiceProvider( cspParams );
-
- // Do not persist the key entry, effectively deleting the key.
- rsa->PersistKeyInCsp = false;
-
- // Call Clear to release the key container resources.
- rsa->Clear();
- Console::WriteLine( "\nKey container released." );
- }
-
- static void DenyOpen()
- {
- try
- {
-
- //
- // Create a KeyContainerPermission with the right to open the key container.
- KeyContainerPermission ^ keyContainerPerm = gcnew KeyContainerPermission( KeyContainerPermissionFlags::Open );
-
- //
- // Demonstrate the results of a deny for an open action.
- keyContainerPerm->Deny();
-
- // The next line causes an exception to be thrown when the infrastructure code attempts
- // to open the key container.
- CspKeyContainerInfo ^ info = gcnew CspKeyContainerInfo( cspParams );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Expected exception thrown: {0}", e->Message );
- }
-
-
- // Revert the deny.
- CodeAccessPermission::RevertDeny();
- }
-
- static void DeleteContainer()
- {
- try
- {
-
- // Create a KeyContainerPermission with the right to create a key container.
- KeyContainerPermission ^ keyContainerPerm = gcnew KeyContainerPermission( KeyContainerPermissionFlags::Create );
-
- // Deny the ability to create a key container.
- // This deny is used to show the key container has been successfully deleted.
- keyContainerPerm->Deny();
-
- // Retrieve the key from the container.
- // This code executes successfully because the key container already exists.
- // The deny for permission to create a key container does not affect this method call.
- GetKeyFromContainer( "MyKeyContainer" );
-
- // Delete the key and the container.
- DeleteKeyContainer( "MyKeyContainer" );
-
- // Attempt to obtain the key from the deleted key container.
- // This time the method call results in an exception because of
- // an attempt to create a new key container.
- Console::WriteLine( "\nAttempt to create a new key container with create permission denied." );
- GetKeyFromContainer( "MyKeyContainer" );
- }
- catch ( CryptographicException^ e )
- {
- Console::WriteLine( "Expected exception thrown: {0}", e->Message );
- }
-
- }
-
-};
-
-int main()
-{
- return KeyContainerPermissionDemo::Main();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp
deleted file mode 100644
index 953013ec45d..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/CPP/nameidpermission.cpp
+++ /dev/null
@@ -1,280 +0,0 @@
-#define debug 0
-
-//
-//#define debug
-// This custom permission is intended only for the purposes of illustration.
-// The following code shows how to create a custom permission that inherits
-// from CodeAccessPermission. The code implements all required overrides.
-// A wildcard character ('*') is implemented for the Name property.
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::IO;
-using namespace System::Security::Policy;
-using namespace System::Collections;
-using namespace System::Text;
-
-[assembly:System::Reflection::AssemblyKeyFile("Key.snk")];
-[assembly:System::Security::AllowPartiallyTrustedCallersAttribute];
-
-[Serializable]
-public ref class NameIdPermission: public CodeAccessPermission, public IUnrestrictedPermission
-{
-private:
- String^ m_Name;
- bool m_Unrestricted;
-
-public:
- NameIdPermission( String^ name )
- {
- m_Name = name;
- }
-
- NameIdPermission( PermissionState state )
- {
- if ( state == PermissionState::None )
- {
- m_Name = "";
- }
- else if ( state == PermissionState::Unrestricted )
- {
- throw gcnew ArgumentException( "Unrestricted state is not allowed for identity permissions." );
- }
- else
- {
- throw gcnew ArgumentException( "Invalid permission state." );
- }
- }
-
- property String^ Name
- {
- String^ get()
- {
- return m_Name;
- }
- void set( String^ value )
- {
- m_Name = value;
- }
- }
-
- //
-public:
- virtual IPermission^ Copy() override
- {
- String^ name = m_Name;
- return gcnew NameIdPermission( name );
- }
- //
-
- //
-public:
- virtual bool IsUnrestricted()
- {
- // Always false, unrestricted state is not allowed.
- return m_Unrestricted;
- }
- //
-
-private:
- bool VerifyType( IPermission^ target )
- {
- return dynamic_cast(target) != nullptr;
- }
-
- //
-public:
- virtual bool IsSubsetOf( IPermission^ target ) override
- {
-#if ( debug )
- Console::WriteLine( "************* Entering IsSubsetOf *********************" );
-#endif
-
- if ( target == nullptr )
- {
- Console::WriteLine( "IsSubsetOf: target == null" );
- return false;
- }
-
-#if ( debug )
- Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
- Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
-#endif
-
- try
- {
- NameIdPermission^ operand = dynamic_cast(target);
-
- // The following check for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if ( true == operand->m_Unrestricted )
- {
- return true;
- }
- else if ( true == this->m_Unrestricted )
- {
- return false;
- }
-
- if ( this->m_Name != nullptr )
- {
- if ( operand->m_Name == nullptr )
- {
- return false;
- }
- if ( this->m_Name->Equals( "" ) )
- {
- return true;
- }
- }
-
- if ( this->m_Name->Equals( operand->m_Name ) )
- {
- return true;
- }
- else
- {
- // Check for wild card character '*'.
- int i = operand->m_Name->LastIndexOf( "*" );
-
- if ( i > 0 )
- {
- String^ prefix = operand->m_Name->Substring( 0, i );
- if ( this->m_Name->StartsWith( prefix ) )
- {
- return true;
- }
- }
- }
- return false;
- }
- catch ( InvalidCastException^ )
- {
- throw gcnew ArgumentException( String::Format( "Argument_WrongType", this->GetType()->FullName ) );
- }
- }
- //
-
- //
-public:
- virtual IPermission^ Intersect( IPermission^ target ) override
- {
- Console::WriteLine( "************* Entering Intersect *********************" );
- if ( target == nullptr )
- {
- return nullptr;
- }
-
-#if ( debug )
- Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
- Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
-#endif
-
- if ( !VerifyType( target ) )
- {
- throw gcnew ArgumentException( String::Format( "Argument is wrong type.", this->GetType()->FullName ) );
- }
-
- NameIdPermission^ operand = dynamic_cast(target);
-
- if ( operand->IsSubsetOf( this ) )
- {
- return operand->Copy();
- }
- else if ( this->IsSubsetOf( operand ) )
- {
- return this->Copy();
- }
- else
- {
- return nullptr;
- }
- }
- //
-
- //
-public:
- virtual IPermission^ Union( IPermission^ target ) override
- {
-#if ( debug )
- Console::WriteLine( "************* Entering Union *********************" );
-#endif
-
- if ( target == nullptr )
- {
- return this;
- }
-
-#if ( debug )
- Console::WriteLine( "This is = {0}", ((NameIdPermission)this).Name );
- Console::WriteLine( "Target is {0}", ((NameIdPermission)target).m_Name );
-#endif
-
- if ( !VerifyType( target ) )
- {
- throw gcnew ArgumentException( String::Format( "Argument_WrongType", this->GetType()->FullName ) );
- }
-
- NameIdPermission^ operand = dynamic_cast(target);
-
- if ( operand->IsSubsetOf( this ) )
- {
- return this->Copy();
- }
- else if ( this->IsSubsetOf( operand ) )
- {
- return operand->Copy();
- }
- else
- {
- return nullptr;
- }
- }
- //
-
- //
-public:
- virtual void FromXml( SecurityElement^ e ) override
- {
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- String^ elUnrestricted = e->Attribute("Unrestricted");
- if ( nullptr != elUnrestricted )
- {
- m_Unrestricted = Boolean::Parse( elUnrestricted );
- return;
- }
-
- String^ elName = e->Attribute("Name");
- m_Name = elName == nullptr ? nullptr : elName;
- }
- //
-
- //
-public:
- virtual SecurityElement^ ToXml() override
- {
- // Use the SecurityElement class to encode the permission to XML.
- SecurityElement^ esd = gcnew SecurityElement( "IPermission" );
- String^ name = NameIdPermission::typeid->AssemblyQualifiedName;
- esd->AddAttribute( "class", name );
- esd->AddAttribute( "version", "1.0" );
-
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if ( m_Unrestricted )
- {
- esd->AddAttribute( "Unrestricted", true.ToString() );
- }
-
- if ( m_Name != nullptr )
- {
- esd->AddAttribute( "Name", m_Name );
- }
-
- return esd;
- }
- //
-};
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/CPP/publisheridentitypermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/CPP/publisheridentitypermission.cpp
deleted file mode 100644
index 603984a43af..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/CPP/publisheridentitypermission.cpp
+++ /dev/null
@@ -1,166 +0,0 @@
-//
-// To execute this sample you will need two certification files, MyCert1.cer and MyCert2.cer.
-// The certification files can be created using the Certification Creation Tool, MakeCert.exe,
-// which runs from the command line. Usage: MakeCert MyCert1.cer
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::IO;
-
-// Demonstrate all methods.
-void main()
-{
- Console::WriteLine("Welcome to the PublisherIdentityPermission CPP sample\n");
-
- array^publisherCertificate = gcnew array(2);
- PublisherIdentityPermission ^ publisherPerm1;
- PublisherIdentityPermission ^ publisherPerm2;
-
- // Initialize the PublisherIdentityPermissions for use in the sample
-//
- FileStream ^ fs1 = gcnew FileStream("MyCert1.cer", FileMode::Open);
- array^certSBytes1 = gcnew array((int)fs1->Length);
- fs1->Read(certSBytes1, 0, (int)fs1->Length);
- publisherCertificate[0] = gcnew X509Certificate(certSBytes1);
- fs1->Close();
-
- FileStream ^ fs2 = gcnew FileStream("MyCert2.cer", FileMode::Open);
- array^certSBytes2 = gcnew array((int)fs2->Length);
- fs2->Read(certSBytes2, 0, (int)fs2->Length);
- publisherCertificate[1] = gcnew X509Certificate(certSBytes2);
- fs2->Close();
-//
-
- publisherPerm1 = gcnew PublisherIdentityPermission(publisherCertificate[0]);
- publisherPerm2 = gcnew PublisherIdentityPermission(publisherCertificate[1]);
-
-//
- Console::WriteLine("\n******************** IsSubsetOf DEMO ********************\n");
- // IsSubsetOf determines whether the current permission is a subset of the specified permission.
- if (publisherPerm2->IsSubsetOf(publisherPerm1))
- Console::WriteLine(publisherPerm2->Certificate->Subject + " is a subset of " +
- publisherPerm1->Certificate->Subject);
- else
- Console::WriteLine(publisherPerm2->Certificate->Subject + " is not a subset of " +
- publisherPerm1->Certificate->Subject);
-//
-
-//
- Console::WriteLine("\n******************** Copy DEMO ********************\n");
- // Copy creates and returns an identical copy of the current permission.
-//
- // Create an empty PublisherIdentityPermission to serve as the target of the copy.
- publisherPerm2 = gcnew PublisherIdentityPermission(PermissionState::None);
- publisherPerm2 = (PublisherIdentityPermission^)publisherPerm1->Copy();
- Console::WriteLine("Result of copy = " + publisherPerm2);
-//
-//
-
-
-//
- Console::WriteLine("\n******************** Union DEMO ********************\n");
- PublisherIdentityPermission ^ publisherPerm3 = (PublisherIdentityPermission ^)publisherPerm1->Union(publisherPerm2);
-
- if (publisherPerm3 == nullptr)
- Console::WriteLine("The union of " + publisherPerm1 + " and " +
- publisherPerm2->Certificate->Subject + " is null.");
- else
- Console::WriteLine("The union of " + publisherPerm1->Certificate->Subject + " and " +
- publisherPerm2->Certificate->Subject + " = " +
- publisherPerm3->Certificate->Subject);
-//
-
-
-//
- // Intersect creates and returns a new permission that is the intersection of the current
- // permission and the permission specified.
- Console::WriteLine("\n******************** Intersect DEMO ********************\n");
- publisherPerm3 = (PublisherIdentityPermission^)publisherPerm1->Intersect(publisherPerm2);
- if (publisherPerm3 != nullptr)
- Console::WriteLine("The intersection of " + publisherPerm1->Certificate->Subject +
- " and " + publisherPerm2->Certificate->Subject + " = " +
- publisherPerm3->Certificate->Subject);
- else
- Console::WriteLine("The intersection of " + publisherPerm1->Certificate->Subject + " and " +
- publisherPerm2->Certificate->Subject + " is null.");
- //
-
-
-//
-// ToXml creates an XML encoding of the permission and its current state;
-// FromXml reconstructs a permission with the specified state from the XML encoding.
- Console::WriteLine("\n******************** ToXml DEMO ********************\n");
- publisherPerm2 = gcnew PublisherIdentityPermission(PermissionState::None);
- publisherPerm2->FromXml(publisherPerm1->ToXml());
- Console::WriteLine("Result of ToFromXml = " + publisherPerm2);
-//
-
- Console::WriteLine("Press Enter to return");
- Console::ReadLine();
-}
-
-/*
-Expected output:
-
-Welcome to the PublisherIdentityPermission CPP sample
-
-
-******************** IsSubsetOf DEMO ********************
-
-CN=Joe's-Software-Emporium is not a subset of CN=Joe's-Software-Emporium
-
-******************** Copy DEMO ********************
-
-Result of copy =
-
-
-******************** Union DEMO ********************
-
-The union of CN=Joe's-Software-Emporium and CN=Joe's-Software-Emporium = CN=Joe'
-s-Software-Emporium
-
-******************** Intersect DEMO ********************
-
-The intersection of CN=Joe's-Software-Emporium and CN=Joe's-Software-Emporium =
-CN=Joe's-Software-Emporium
-
-******************** ToXml DEMO ********************
-
-Result of ToFromXml =
-
-Press Enter to return
-*/
-
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp
deleted file mode 100644
index cfad634f423..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/CPP/securitypermissionattribute.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-
-//
-// This sample demonstrates the use of the SecurityPermissionAttribute.
-using namespace System;
-using namespace System::Security::Permissions;
-using namespace System::Security;
-class MyClass
-{
-public:
- static void PermissionDemo()
- {
- try
- {
- DenySecurityPermissions();
- DenyAllSecurityPermissions();
- DoNotDenySecurityPermissions();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( e->Message );
- }
-
- }
-
-
- // This method demonstrates the use of the SecurityPermissionAttribute to deny individual security permissions.
- //
- // Set the Assertion property.
- [SecurityPermissionAttribute(SecurityAction::Deny,Assertion=true)]
- //
- //
- // Set the ControlAppDomain property.
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlAppDomain=true)]
- //
- //
- // Set the ControlDomainPolicy property.
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlDomainPolicy=true)]
- //
- //
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlEvidence=true)]
- // Set the ControlEvidence property.
- //
- //
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlPolicy=true)]
- // Set the ControlPolicy property.
- //
- //
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlPrincipal=true)]
- // Set the ControlPrincipal property.
- //
- //
- // Set the ControlThread property.
- [SecurityPermissionAttribute(SecurityAction::Deny,ControlThread=true)]
- //
- //
- // Set the Execution property.
- [SecurityPermissionAttribute(SecurityAction::Deny,Execution=true)]
- //
- //
- // Set the Flags property.
- [SecurityPermissionAttribute(SecurityAction::Deny,Flags=SecurityPermissionFlag::NoFlags)]
- //
- //
- // Set the Infrastructure property.
- [SecurityPermissionAttribute(SecurityAction::Deny,Infrastructure=true)]
- //
- //
- // Set the RemotingConfiguration property.
- [SecurityPermissionAttribute(SecurityAction::Deny,RemotingConfiguration=true)]
- //
- //
- // Set the SerializationFormatter property.
- [SecurityPermissionAttribute(SecurityAction::Deny,SerializationFormatter=true)]
- //
- //
- // Set the SkipVerification property.
- [SecurityPermissionAttribute(SecurityAction::Deny,SkipVerification=true)]
- //
- //
- // Set the UnmanagedCode property.
- [SecurityPermissionAttribute(SecurityAction::Deny,UnmanagedCode=true)]
- //
-
- static void DenySecurityPermissions()
- {
- Console::WriteLine( "Executing DenySecurityPermissions." );
- Console::WriteLine( "Denied all permissions individually." );
- TestSecurityPermissions();
- }
-
-
- // This method demonstrates the use of SecurityPermissionFlag::AllFlags to deny all security permissions.
-
- [SecurityPermissionAttribute(SecurityAction::Deny,Flags=SecurityPermissionFlag::AllFlags)]
- static void DenyAllSecurityPermissions()
- {
- Console::WriteLine( "\nExecuting DenyAllSecurityPermissions." );
- Console::WriteLine( "Denied all permissions using SecurityPermissionFlag::AllFlags." );
- TestSecurityPermissions();
- }
-
-
- // This method demonstrates the effect of not denying security permissions.
- static void DoNotDenySecurityPermissions()
- {
- Console::WriteLine( "\nExecuting DoNotDenySecurityPermissions." );
- Console::WriteLine( "No permissions have been denied." );
- DemandSecurityPermissions();
- }
-
- static void TestSecurityPermissions()
- {
- Console::WriteLine( "\nExecuting TestSecurityPermissions.\n" );
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Assertion );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Assertion" );
-
- // This demand should cause an exception.
- sp->Demand();
-
- // The TestFailed method is called if an exception is not thrown.
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Assertion failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlAppDomain );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlAppDomain" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlAppDomain failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlDomainPolicy );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlDomainPolicy" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlDomainPolicy failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlEvidence );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlEvidence" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlEvidence failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPolicy );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPolicy" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPolicy failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPrincipal );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPrincipal" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPrincipal failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlThread );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlThread" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlThread failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Execution );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Execution" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Execution failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Infrastructure );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Infrastructure" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Infrastructure failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::RemotingConfiguration );
- Console::WriteLine( "Demanding SecurityPermissionFlag::RemotingConfiguration" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::RemotingConfiguration failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SerializationFormatter );
- Console::WriteLine( "Demanding SecurityPermissionFlag::SerializationFormatter" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::SerializationFormatter failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SkipVerification );
- Console::WriteLine( "Demanding SecurityPermissionFlag::SkipVerification" );
- sp->Demand();
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::SkipVerification failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::UnmanagedCode );
- Console::WriteLine( "Demanding SecurityPermissionFlag::UnmanagedCode" );
-
- // This demand should cause an exception.
- sp->Demand();
-
- // The TestFailed method is called if an exception is not thrown.
- TestFailed();
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::UnmanagedCode failed: {0}", e->Message );
- }
-
- }
-
- static void TestFailed()
- {
- Console::WriteLine( "In TestFailed method." );
- Console::WriteLine( "Throwing an exception." );
- throw gcnew Exception;
- }
-
-//
- static void DemandSecurityPermissions()
- {
- Console::WriteLine( "\nExecuting DemandSecurityPermissions.\n" );
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Assertion );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Assertion" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::Assertion succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Assertion failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlAppDomain );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlAppDomain" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlAppDomain succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlAppDomain failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlDomainPolicy );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlDomainPolicy" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlDomainPolicy succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlDomainPolicy failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlEvidence );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlEvidence" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlEvidence succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlEvidence failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPolicy );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPolicy" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPolicy succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPolicy failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlPrincipal );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlPrincipal" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPrincipal succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlPrincipal failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::ControlThread );
- Console::WriteLine( "Demanding SecurityPermissionFlag::ControlThread" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlThread succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::ControlThread failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Execution );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Execution" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::Execution succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Execution failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::Infrastructure );
- Console::WriteLine( "Demanding SecurityPermissionFlag::Infrastructure" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::Infrastructure succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::Infrastructure failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::RemotingConfiguration );
- Console::WriteLine( "Demanding SecurityPermissionFlag::RemotingConfiguration" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::RemotingConfiguration succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::RemotingConfiguration failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SerializationFormatter );
- Console::WriteLine( "Demanding SecurityPermissionFlag::SerializationFormatter" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::SerializationFormatter succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::SerializationFormatter failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::SkipVerification );
- Console::WriteLine( "Demanding SecurityPermissionFlag::SkipVerification" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::SkipVerification succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::SkipVerification failed: {0}", e->Message );
- }
-
- try
- {
- SecurityPermission^ sp = gcnew SecurityPermission( SecurityPermissionFlag::UnmanagedCode );
- Console::WriteLine( "Demanding SecurityPermissionFlag::UnmanagedCode" );
- sp->Demand();
- Console::WriteLine( "Demand for SecurityPermissionFlag::UnmanagedCode succeeded." );
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "Demand for SecurityPermissionFlag::UnmanagedCode failed: {0}", e->Message );
- }
-
- }
-//
-
-};
-
-int main()
-{
- MyClass::PermissionDemo();
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/CPP/storepermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/CPP/storepermission.cpp
deleted file mode 100644
index 1cf6f037e02..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/CPP/storepermission.cpp
+++ /dev/null
@@ -1,143 +0,0 @@
-
-
-//
-#using
-#using
-
-using namespace System;
-using namespace System::Security::Permissions;
-using namespace System::Security::Cryptography;
-using namespace System::Security::Cryptography::X509Certificates;
-using namespace System::Security;
-using namespace System::IO;
-
-[assembly:StorePermissionAttribute(SecurityAction::RequestMinimum,
-Flags=StorePermissionFlags::DeleteStore)];
-void AddToStore( X509Certificate2 ^ cert );
-void ShowMembers();
-int main()
-{
-
- //
- Console::WriteLine( "Creating a permission with Flags = OpenStore." );
- StorePermission^ sp = gcnew StorePermission( StorePermissionFlags::OpenStore );
-
- //
- //Create a new X509 store named teststore from the local certificate store.
- //You must put in a valid path to a certificate in the following constructor.
- X509Certificate2^ certificate = gcnew X509Certificate2( "c:\\certificates\\*****.cer" );
-
- // Deny the permission to open a store.
- sp->Deny();
-
- // The following code results in an exception due to an attempt to open a store.
- AddToStore( certificate );
-
- // Remove the deny for opening a store.
- CodeAccessPermission::RevertDeny();
-
- // The following code results in an exception due to an attempt to add a certificate.
- // The exception is thrown due to a StorePermissionAttribute on the method denying AddToStore permission.
- AddToStore( certificate );
-
- // The current code is not affected by the attribute in the previously called method, so the following
- // intructions execute without an exception.
- X509Store^ store = gcnew X509Store( "teststore",StoreLocation::CurrentUser );
- store->Open( OpenFlags::ReadWrite );
- store->Add( certificate );
-
- // Demonstrate the behavior of the class members.
- ShowMembers();
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadKey();
-}
-
-
-//
-//Deny the permission the ability to add to a store.
-
-[StorePermission(SecurityAction::Deny,Flags=StorePermissionFlags::AddToStore)]
-void AddToStore( X509Certificate2^ cert )
-{
- try
- {
- X509Store^ store = gcnew 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: {0}",
- (dynamic_cast(e->FirstPermissionThatFailed))->Flags );
- return;
- }
-
-}
-
-
-//
-// The following function is intended to demonstrate only the behavior of
-// StorePermission class members,and not their practical usage. Most properties
-// and methods in this class are used for the resolution and enforcement of
-// security policy by the security infrastructure code.
-void ShowMembers()
-{
- Console::WriteLine( "Creating first permission with Flags = OpenStore." );
- StorePermission^ sp1 = gcnew StorePermission( StorePermissionFlags::OpenStore );
- Console::WriteLine( "Creating second permission with Flags = AllFlags." );
- StorePermission^ sp2 = gcnew StorePermission( StorePermissionFlags::AllFlags );
- Console::WriteLine( "Creating third permission as Unrestricted." );
-
- //
- StorePermission^ sp3 = gcnew StorePermission( PermissionState::Unrestricted );
-
- //
- Console::WriteLine( "Creating fourth permission with a permission state of none." );
- StorePermission^ sp4 = gcnew StorePermission( PermissionState::None );
-
- //
- bool rc = sp2->IsSubsetOf( sp3 );
- Console::WriteLine( "Is the permission with complete store access (AllFlags) a subset of \n"
- "\tthe permission with an Unrestricted permission state? {0}", (rc ? (String^)"Yes" : "No") );
- rc = sp1->IsSubsetOf( sp2 );
- Console::WriteLine( "Is the permission with OpenStore access a subset of the permission with \n"
- "\tcomplete store access (AllFlags)? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- rc = sp3->IsUnrestricted();
- Console::WriteLine( "Is the third permission unrestricted? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- Console::WriteLine( "Copying the second permission to the fourth permission." );
- sp4 = dynamic_cast(sp2->Copy());
- rc = sp4->Equals( sp2 );
- Console::WriteLine( "Is the fourth permission equal to the second permission? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
- //
- Console::WriteLine( "Creating the intersection of the second and first permissions." );
- sp4 = dynamic_cast(sp2->Intersect( sp1 ));
- Console::WriteLine( "Value of the Flags property is: {0}", sp4->Flags );
-
- //
- //
- Console::WriteLine( "Creating the union of the second and first permissions." );
- sp4 = dynamic_cast(sp2->Union( sp1 ));
- Console::WriteLine( "Result of the union of the second permission with the first: {0}", sp4->Flags );
-
- //
- //
- Console::WriteLine( "Using an XML roundtrip to reset the fourth permission." );
- sp4->FromXml( sp2->ToXml() );
- rc = sp4->Equals( sp2 );
- Console::WriteLine( "Does the XML roundtrip result equal the original permission? {0}", (rc ? (String^)"Yes" : "No") );
-
- //
-}
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp
deleted file mode 100644
index 6fbc207a89a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/CPP/strongnameidentity.cpp
+++ /dev/null
@@ -1,244 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Runtime::InteropServices;
-
-// This class generates StrongNameIdentityPermission objects.
-
-[assembly:CLSCompliant(true)];
-
-public ref class StrongNameIdentityDemo
-{
-private:
- // Public key
- static array^b1 = {0,36,0,0,4,128,0,0,148,0,0,0,6,2,0,0,0,36,0,0,82,83,65,49,0,4,0,0,1,0,1,0,237,146,145,51,34,97,123,196,90,174,41,170,173,221,41,193,175,39,7,151,178,0,230,152,218,8,206,206,170,84,111,145,26,208,158,240,246,219,228,34,31,163,11,130,16,199,111,224,4,112,46,84,0,104,229,38,39,63,53,189,0,157,32,38,34,109,0,171,114,244,34,59,9,232,150,192,247,175,104,143,171,42,219,66,66,194,191,218,121,59,92,42,37,158,13,108,210,189,9,203,204,32,48,91,212,101,193,19,227,107,25,133,70,2,220,83,206,71,102,245,104,252,87,109,190,56,34,180};
- static StrongNamePublicKeyBlob^ blob = gcnew StrongNamePublicKeyBlob( b1 );
-
- // Use this version number.
- static Version^ v1 = gcnew Version( "1.0.0.0" );
-
- //
- // IsSubsetOf determines whether the current permission is a subset of the specified permission.
- bool IsSubsetOfDemo()
- {
- bool returnValue = true;
-
- StrongNameIdentityPermission^ snIdPerm1;
- StrongNameIdentityPermission^ snIdPerm2;
-
- //
- snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
- //
- snIdPerm2 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", gcnew Version("1.0.0.0"));
-
- if (snIdPerm1->IsSubsetOf(snIdPerm2))
- {
-
- Console::WriteLine("MyCompany.MyDepartment.* is a subset " +
- "of MyCompany.MyDepartment.MyFile \n");
- }
- else
- {
- Console::WriteLine("MyCompany.MyDepartment.*" +
- " is not a subset of MyCompany.MyDepartment.MyFile \n");
- }
-
- return returnValue;
- }
-
-
- //
- //
- // Union creates a new permission that is the union of the current permission and the specified permission.
- bool UnionDemo()
- {
- bool returnValue = true;
- StrongNameIdentityPermission^ snIdPerm1;
- StrongNameIdentityPermission^ snIdPerm2;
- IPermission^ snIdPerm3;
- snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
- snIdPerm2 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", gcnew Version("1.0.0.0"));
- snIdPerm3 = dynamic_cast(snIdPerm1->Union( snIdPerm2 ));
- snIdPerm3 = snIdPerm1->Union( snIdPerm2 );
-
- try
- {
- Console::WriteLine("The union of MyCompany.MyDepartment.*" +
- "and MyCompany.MyDepartment.MyFile is " +
- (dynamic_cast(snIdPerm3))->Name);
- }
- catch (Exception^ e)
- {
- Console::WriteLine("An expected exception was thrown: " + e->Message);
- }
-
-
- return returnValue;
- }
-
-
- //
- //
- // Intersect creates and returns a new permission that is the intersection of the current
- // permission and the permission specified.
- bool IntersectDemo()
- {
- bool returnValue = true;
- StrongNameIdentityPermission^ snIdPerm1;
- StrongNameIdentityPermission^ snIdPerm2;
- StrongNameIdentityPermission^ snIdPerm3;
- snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
- snIdPerm2 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", gcnew Version("1.0.0.0"));
-
- try
- {
-
- snIdPerm3 = dynamic_cast(snIdPerm1->Intersect(snIdPerm2));
-
- Console::WriteLine("The intersection of MyCompany.MyDepartment.*" +
- "and MyCompany.MyDepartment.MyFile is " +
- (dynamic_cast(snIdPerm3))->Name);
- }
- catch (Exception^ e)
- {
- Console::WriteLine("An exception was thrown: " + e);
- returnValue = false;
- }
-
- return returnValue;
-
- }
-
-
- //
- //
- //Copy creates and returns an identical copy of the current permission.
- bool CopyDemo()
- {
- bool returnValue = true;
- StrongNameIdentityPermission^ snIdPerm1;
- StrongNameIdentityPermission^ snIdPerm2;
- snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
- //
- snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
- //
-
- snIdPerm2 = dynamic_cast(snIdPerm1->Copy());
- Console::WriteLine("Result of copy = " + snIdPerm2->ToString() + "\n");
-
- return returnValue;
- }
-
-
- //
- //
- // ToXml creates an XML encoding of the permission and its current state;
- //FromXml reconstructs a permission with the specified state from the XML encoding.
- bool ToFromXmlDemo()
- {
- bool returnValue = true;
- StrongNameIdentityPermission^ snIdPerm1;
- StrongNameIdentityPermission^ snIdPerm2;
- snIdPerm1 = gcnew StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", gcnew Version("1.0.0.0"));
- snIdPerm2 = gcnew StrongNameIdentityPermission(PermissionState::None);
- snIdPerm2->FromXml(snIdPerm1->ToXml());
- Console::WriteLine("Result of ToFromXml = " + snIdPerm2->ToString() + "\n");
-
- return returnValue;
- }
-
-
-public:
-
- //
- // Invoke all demos.
- bool RunDemo()
- {
- bool ret = true;
- bool retTmp;
-
- // Call the IsSubsetOf demo.
- if ( retTmp = IsSubsetOfDemo() )
- Console::WriteLine( "IsSubsetOf demo completed successfully." );
- else
- Console::WriteLine( "IsSubsetOf demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Union demo.
- if ( retTmp = UnionDemo() )
- Console::WriteLine( "Union demo completed successfully." );
- else
- Console::WriteLine( "Union demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Intersect demo.
- if ( retTmp = IntersectDemo() )
- Console::WriteLine( "Intersect demo completed successfully." );
- else
- Console::WriteLine( "Intersect demo failed." );
-
- ret = retTmp && ret;
-
- // Call the Copy demo.
- if ( retTmp = CopyDemo() )
- Console::WriteLine( "Copy demo completed successfully" );
- else
- Console::WriteLine( "Copy demo failed." );
-
- ret = retTmp && ret;
-
- // Call the ToFromXml demo.
- if ( retTmp = ToFromXmlDemo() )
- Console::WriteLine( "ToFromXml demo completed successfully" );
- else
- Console::WriteLine( "ToFromXml demo failed." );
-
- ret = retTmp && ret;
- Console::WriteLine( "********************************************************\n" );
- return (ret);
- }
-
-};
-
-
-// Test harness.
-int main()
-{
- try
- {
- StrongNameIdentityDemo^ democase = gcnew StrongNameIdentityDemo;
- bool ret = democase->RunDemo();
- if ( ret )
- {
- Console::WriteLine( "StrongNameIdentity demo completed successfully." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 100;
- }
- else
- {
- Console::WriteLine( "StrongNameIdentity demo failed." );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
- }
- catch ( Exception^ e )
- {
- Console::WriteLine( "StrongNameIdentity demo failed." );
- Console::WriteLine( e );
- Console::WriteLine( "Press the Enter key to exit." );
- Console::ReadLine();
- System::Environment::ExitCode = 101;
- }
-
-}
-
-//
-
-
-
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp
deleted file mode 100644
index 2ff0e156c43..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/CPP/uipermission.cpp
+++ /dev/null
@@ -1,178 +0,0 @@
-// UIPermCPP.cpp : main project file.
-
-
-
-//
-// This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml and FromXml methods
-// of the UIPermission class.
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Runtime::InteropServices;
-
-void IsSubsetOfDemo(); // Forward references
-void CopyDemo();
-void UnionDemo();
-void IntersectDemo();
-void ToFromXmlDemo();
-
-
-int main()
-{
- IsSubsetOfDemo();
- CopyDemo();
- UnionDemo();
- IntersectDemo();
- ToFromXmlDemo();
-}
-
-
-
-//
-// IsSubsetOf determines whether the current permission is a subset of the specified permission.
-
-void IsSubsetOfDemo()
-{
- Console::WriteLine("\n********************** IsSubsetOf() Demo **********************\n");
-//
- UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
-//
- UIPermission ^ uiPerm2 = gcnew UIPermission(UIPermissionWindow::SafeSubWindows);
-
- Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm1->Window,
- uiPerm1->IsSubsetOf(uiPerm2)?"":"not ", uiPerm2->Window);
-
- Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm2->Window,
- uiPerm2->IsSubsetOf(uiPerm1)?"":"not ", uiPerm1->Window);
-
-//
- uiPerm1 = gcnew UIPermission(UIPermissionClipboard::AllClipboard);
-//
- uiPerm2 = gcnew UIPermission(UIPermissionClipboard::OwnClipboard);
-
- Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm1->Clipboard,
- uiPerm1->IsSubsetOf(uiPerm2)?"":"not ", uiPerm2->Clipboard);
-
- Console::WriteLine(" {0} is {1}a subset of {2} ", uiPerm2->Clipboard,
- uiPerm2->IsSubsetOf(uiPerm1)?"":"not ", uiPerm1->Clipboard);
-}
-//
-
-
-
-//
- // Union creates a new permission that is the union of the current permission
- // and the specified permission.
-void UnionDemo()
-{
- Console::WriteLine("\n************************ Union() Demo *************************\n");
-
- UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
- UIPermission ^ uiPerm2 = gcnew UIPermission(UIPermissionWindow::SafeSubWindows);
-
- UIPermission ^ p3 = dynamic_cast(uiPerm1->Union(uiPerm2));
- Console::WriteLine(" The union of {0} and \n\t{1} = {2} ", uiPerm1->Window,
- uiPerm2->Window, (nullptr != p3)?p3->Window.ToString():"null");
-}
-//
-
-//
-// Intersect creates and returns a new permission that is the intersection of the
-// current permission and the permission specified.
-void IntersectDemo()
-{
- Console::WriteLine("\n********************** Intersect() Demo ***********************\n");
-//
- UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows,UIPermissionClipboard::OwnClipboard);
-//
- UIPermission ^ uiPerm2 = gcnew UIPermission(UIPermissionWindow::SafeSubWindows,UIPermissionClipboard::NoClipboard);
- UIPermission ^ p3 = (UIPermission^)uiPerm1->Intersect(uiPerm2);
-
- Console::WriteLine(" The intersection of {0} and \n\t{1} = {2} ", uiPerm1->Window,
- uiPerm1->Window, (nullptr != p3)?p3->Window.ToString():"null");
-
- Console::WriteLine(" The intersection of " + uiPerm1->Clipboard.ToString() + " and \n\t" +
- uiPerm2->Clipboard.ToString() + " is " + p3->Clipboard.ToString());
-}
-//
-
-
-//
-//Copy creates and returns an identical copy of the current permission.
-void CopyDemo()
-{
- Console::WriteLine("\n************************* Copy() Demo *************************\n");
-
- UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
- //
- UIPermission ^ uiPerm2 = gcnew UIPermission(PermissionState::None);
- //
- uiPerm2 = (UIPermission ^)uiPerm1->Copy();
- if (uiPerm2 != nullptr)
- Console::WriteLine("The copy succeeded: " + uiPerm2->ToString());
-}
-//
-
-//
-
-// ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
-// permission with the specified state from the XML encoding.
-void ToFromXmlDemo()
-{
- Console::WriteLine("\n********************** To/From XML() Demo *********************\n");
-
- UIPermission ^ uiPerm1 = gcnew UIPermission(UIPermissionWindow::SafeTopLevelWindows);
- UIPermission ^ uiPerm2 = gcnew UIPermission(PermissionState::None);
- uiPerm2->FromXml(uiPerm1->ToXml());
- bool result = uiPerm2->Equals(uiPerm1);
- if (result)
- Console::WriteLine("Result of ToFromXml = " + uiPerm2->ToString());
- else
- {
- Console::WriteLine(uiPerm2->ToString());
- Console::WriteLine(uiPerm1->ToString());
- }
-}
-//
-//
-
-/*
-// This code example creates the following output:
-
-********************** IsSubsetOf() Demo **********************
-
- SafeTopLevelWindows is not a subset of SafeSubWindows
- SafeSubWindows is a subset of SafeTopLevelWindows
- AllClipboard is not a subset of OwnClipboard
- OwnClipboard is a subset of AllClipboard
-
-************************* Copy() Demo *************************
-
-The copy succeeded:
-
-
-************************ Union() Demo *************************
-
- The union of SafeTopLevelWindows and
- SafeSubWindows = SafeTopLevelWindows
-
-********************** Intersect() Demo ***********************
-
- The intersection of SafeTopLevelWindows and
- SafeTopLevelWindows = SafeSubWindows
- The intersection of OwnClipboard and
- NoClipboard is NoClipboard
-
-********************** To/From XML() Demo *********************
-
-Result of ToFromXml =
-
-*/
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp
deleted file mode 100644
index ba4df789e20..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/CPP/urlidentity.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Runtime::InteropServices;
-
-void IsSubsetOfDemo(); // Forward references
-void CopyDemo();
-void IntersectDemo();
-void ToFromXmlDemo();
-
-void main()
-{
- IsSubsetOfDemo();
- CopyDemo();
- IntersectDemo();
- ToFromXmlDemo();
-
- Console::WriteLine("\n\nPress ENTER to return");
- Console::ReadLine();
-}
-
-//
-// IsSubsetOf determines whether the current permission is a subset of the specified permission.
-void IsSubsetOfDemo()
-{
- //
- UrlIdentityPermission ^ permIdPerm1 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/process/");
- //
- UrlIdentityPermission ^ permIdPerm2 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/*");
-
- if (permIdPerm1->IsSubsetOf(permIdPerm2))
- Console::WriteLine(permIdPerm1->Url + " is a subset of " + permIdPerm2->Url);
- else Console::WriteLine(permIdPerm1->Url + " is not a subset of " + permIdPerm2->Url);
- if (permIdPerm2->IsSubsetOf(permIdPerm1))
- Console::WriteLine(permIdPerm2->Url + " is a subset of " + permIdPerm1->Url);
- else Console::WriteLine(permIdPerm2->Url + " is not a subset of " + permIdPerm1->Url);
-}
-//
-
-//
-// Intersect creates and returns a gcnew permission that is the intersection of the
-// current permission and the permission specified.
-void IntersectDemo()
-{
-
- UrlIdentityPermission ^ permIdPerm1 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/process/");
- UrlIdentityPermission ^ permIdPerm2 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/*");
- UrlIdentityPermission ^ p3 = (UrlIdentityPermission^)permIdPerm1->Intersect(permIdPerm2);
-
- if (p3 != nullptr)
- Console::WriteLine("The intersection of " + permIdPerm1->Url + " and \n\t" +
- permIdPerm2->Url + " is " + p3->Url + "\n");
- else Console::WriteLine("The intersection of " + permIdPerm1->Url +
- " and \n\t" + permIdPerm2->Url + " is null.\n");
-}
-//
-
-//
-//Copy creates and returns an identical copy of the current permission.
-void CopyDemo()
-{
- UrlIdentityPermission ^ permIdPerm1 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/process/*");
- //
- UrlIdentityPermission ^ permIdPerm2 = gcnew UrlIdentityPermission(PermissionState::None);
- //
- permIdPerm2 = (UrlIdentityPermission^)permIdPerm1->Copy();
- if (permIdPerm2)
- Console::WriteLine("The copy succeeded: " + permIdPerm2->ToString() + " \n");
-}
-//
-
-//
-// ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
-// permission with the specified state from the XML encoding.
-void ToFromXmlDemo()
-{
- UrlIdentityPermission ^ permIdPerm1 = gcnew UrlIdentityPermission("http://www.fourthcoffee.com/process/*");
- UrlIdentityPermission ^ permIdPerm2 = gcnew UrlIdentityPermission(PermissionState::None);
- permIdPerm2->FromXml(permIdPerm1->ToXml());
- bool result = permIdPerm2->Equals(permIdPerm1);
- if (result)
- Console::WriteLine("Result of ToFromXml = " + permIdPerm2->ToString());
- else
- {
- Console::WriteLine(permIdPerm2->ToString());
- Console::WriteLine(permIdPerm1->ToString());
- }
-
-}
-//
-
-
-
-//
-// This code example creates the following output:
-
-//http://www.fourthcoffee.com/process/ is a subset of http://www.fourthcoffee.com/
-//*
-//http://www.fourthcoffee.com/* is not a subset of http://www.fourthcoffee.com/pro
-//cess/
-//The copy succeeded:
-
-
-//The union of http://www.fourthcoffee.com/process/ and
-// http://www.fourthcoffee.com/* failed.
-//The operation is ambiguous because the permission represents multiple identities
-//.
-//The intersection of http://www.fourthcoffee.com/process/ and
-// http://www.fourthcoffee.com/* is http://www.fourthcoffee.com/process/
-
-//Result of ToFromXml =
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp
deleted file mode 100644
index 6c337fe9923..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/CPP/members.cpp
+++ /dev/null
@@ -1,314 +0,0 @@
-// This sample demonstrates how to use each member of the FileCodeGroup class.
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Policy;
-using namespace System::Security::Permissions;
-using namespace System::Reflection;
-
-ref class Members
-{
-public:
- [STAThread]
- static void Main()
- {
- FileCodeGroup^ fileCodeGroup = constructDefaultGroup();
-
- // Create a deep copy of the FileCodeGroup.
- //
- FileCodeGroup^ copyCodeGroup =
- dynamic_cast(fileCodeGroup->Copy());
- //
-
- CompareTwoCodeGroups( fileCodeGroup, copyCodeGroup );
- addPolicy( &fileCodeGroup );
- addXmlMember( &fileCodeGroup );
- updateMembershipCondition( &fileCodeGroup );
- addChildCodeGroup( &fileCodeGroup );
- Console::Write( L"Comparing the resolved code group " );
- Console::WriteLine( L"with the initial code group." );
- FileCodeGroup^ resolvedCodeGroup =
- ResolveGroupToEvidence( fileCodeGroup );
- if ( CompareTwoCodeGroups( fileCodeGroup, resolvedCodeGroup ) )
- {
- PrintCodeGroup( resolvedCodeGroup );
- }
- else
- {
- PrintCodeGroup( fileCodeGroup );
- }
-
- Console::WriteLine( L"This sample completed successfully; press Enter to exit." );
- Console::ReadLine();
- }
-
-private:
- // Construct a new FileCodeGroup with Read, Write, Append
- // and PathDiscovery access.
- static FileCodeGroup^ constructDefaultGroup()
- {
- // Construct a new file code group that has complete access to
- // files in the specified path.
- //
- FileCodeGroup^ fileCodeGroup = gcnew FileCodeGroup(
- gcnew AllMembershipCondition,FileIOPermissionAccess::AllAccess );
- //
-
- // Set the name of the file code group.
- //
- fileCodeGroup->Name = L"TempCodeGroup";
- //
-
- // Set the description of the file code group.
- //
- fileCodeGroup->Description = L"Temp folder permissions group";
- //
-
- // Retrieve the string representation of the fileCodeGroup�s
- // attributes. FileCodeGroup does not use AttributeString, so the
- // value should be null.
- //
- if ( fileCodeGroup->AttributeString != nullptr )
- {
- throw gcnew NullReferenceException(
- L"The AttributeString property should be null." );
- }
- //
-
- return fileCodeGroup;
- }
-
- // Add file permission to restrict write access to all files on the
- // local machine.
- static void addPolicy( interior_ptr fileCodeGroup )
- {
- // Set the PolicyStatement property to a policy with read access to
- // the root directory of drive C.
- //
- FileIOPermission^ rootFilePermissions =
- gcnew FileIOPermission( PermissionState::None );
- rootFilePermissions->AllLocalFiles =
- FileIOPermissionAccess::Read;
- rootFilePermissions->SetPathList(
- FileIOPermissionAccess::Read, L"C:\\" );
- NamedPermissionSet^ namedPermissions =
- gcnew NamedPermissionSet( L"RootPermissions" );
- namedPermissions->AddPermission( rootFilePermissions );
- ( *fileCodeGroup )->PolicyStatement =
- gcnew PolicyStatement( namedPermissions );
- //
- }
-
- // Set the membership condition of the specified FileCodeGroup
- // to the Intranet zone.
- static void updateMembershipCondition( interior_ptr fileCodeGroup )
- {
- //
- ZoneMembershipCondition^ zoneCondition =
- gcnew ZoneMembershipCondition( SecurityZone::Intranet );
- ( *fileCodeGroup )->MembershipCondition = zoneCondition;
- //
- }
-
- // Add a child group with read-access file permission to the specified
- // code group.
- static void addChildCodeGroup( interior_ptr fileCodeGroup )
- {
- // Create a file code group with read-access permission.
- //
- FileCodeGroup^ tempFolderCodeGroup = gcnew FileCodeGroup(
- gcnew AllMembershipCondition,FileIOPermissionAccess::Read );
-
- // Set the name of the child code group and add it to
- // the specified code group.
- tempFolderCodeGroup->Name = L"Read-only group";
- ( *fileCodeGroup )->AddChild( tempFolderCodeGroup );
- //
- }
-
- // Compare the two specified file code groups for equality.
- static bool CompareTwoCodeGroups( FileCodeGroup^ firstCodeGroup,
- FileCodeGroup^ secondCodeGroup )
- {
- //
- if ( firstCodeGroup->Equals( secondCodeGroup ) )
- //
- {
- Console::WriteLine( L"The two code groups are equal." );
- return true;
- }
- else
- {
- Console::WriteLine( L"The two code groups are not equal." );
- return false;
- }
- }
-
- // Retrieve the resolved policy based on Evidence from the executing
- // assembly found in the specified code group.
- static String^ ResolveEvidence( CodeGroup^ fileCodeGroup )
- {
- String^ policyString = L"";
-
- // Resolve the policy based on evidence in the executing assembly.
- //
- Assembly^ assembly = Members::typeid->Assembly;
- Evidence^ executingEvidence = assembly->Evidence;
- PolicyStatement^ policy = fileCodeGroup->Resolve( executingEvidence );
- //
-
- if ( policy != nullptr )
- {
- policyString = policy->ToString();
- }
-
- return policyString;
- }
-
- // Retrieve the resolved code group based on the Evidence from
- // the executing assembly found in the specified code group.
- static FileCodeGroup^ ResolveGroupToEvidence( FileCodeGroup^ fileCodeGroup )
- {
- // Resolve matching code groups to the executing assembly.
- //
- Assembly^ assembly = Members::typeid->Assembly;
- Evidence^ evidence = assembly->Evidence;
- CodeGroup^ codeGroup = fileCodeGroup->ResolveMatchingCodeGroups( evidence );
- //
-
- return dynamic_cast(codeGroup);
- }
-
- // If a domain attribute is not found in the specified FileCodeGroup,
- // add a child XML element identifying a custom membership condition.
- static void addXmlMember( interior_ptr fileCodeGroup )
- {
- //
- SecurityElement^ xmlElement = ( *fileCodeGroup )->ToXml();
- //
-
- SecurityElement^ rootElement = gcnew SecurityElement( L"CodeGroup" );
- if ( xmlElement->Attribute(L"domain") == nullptr )
- {
- //
- SecurityElement^ newElement = gcnew SecurityElement(
- L"CustomMembershipCondition" );
- newElement->AddAttribute( L"class", L"CustomMembershipCondition" );
- newElement->AddAttribute( L"version", L"1" );
- newElement->AddAttribute( L"domain", L"contoso.com" );
- rootElement->AddChild( newElement );
- ( *fileCodeGroup )->FromXml( rootElement );
- //
- }
-
- Console::WriteLine( L"Added a custom membership condition:" );
- Console::WriteLine( rootElement );
- }
-
- // Print the properties of the specified code group to the console.
- static void PrintCodeGroup( CodeGroup^ codeGroup )
- {
- // Compare the type of the specified object with the FileCodeGroup
- // type.
- //
- if ( !codeGroup->GetType()->Equals( FileCodeGroup::typeid ) )
- //
- {
- throw gcnew ArgumentException( L"Expected the FileCodeGroup type." );
- }
-
- String^ codeGroupName = codeGroup->Name;
- String^ membershipCondition = codeGroup->MembershipCondition->ToString();
-
- //
- String^ permissionSetName = codeGroup->PermissionSetName;
- //
-
- //
- int hashCode = codeGroup->GetHashCode();
- //
-
- String^ mergeLogic = L"";
-
- //
- if ( codeGroup->MergeLogic->Equals( L"Union" ) )
- {
- mergeLogic = L" with Union merge logic";
- }
- //
-
- // Retrieve the class path for FileCodeGroup.
- //
- String^ fileGroupClass = codeGroup->ToString();
-
- //
- // Write summary to the console window.
- Console::WriteLine( L"\n*** {0} summary ***", fileGroupClass );
- Console::Write( L"A FileCodeGroup named " );
- Console::Write( L"{0}{1}", codeGroupName, mergeLogic );
- Console::Write( L" has been created with hash code{0}.", hashCode );
- Console::Write( L"This code group contains a {0}", membershipCondition );
- Console::Write( L" membership condition with the " );
- Console::Write( L"{0} permission set. ", permissionSetName );
- Console::Write( L"The code group has the following security policy: " );
- Console::WriteLine( ResolveEvidence( codeGroup ) );
- int childCount = codeGroup->Children->Count;
- if ( childCount > 0 )
- {
- Console::Write( L"There are {0}", childCount );
- Console::WriteLine( L" child code groups in this code group." );
-
- // Iterate through the child code groups to display their names
- // and remove them from the specified code group.
- for ( int i = 0; i < childCount; i++ )
- {
- // Get child code group as type FileCodeGroup.
- //
- FileCodeGroup^ childCodeGroup =
- dynamic_cast(codeGroup->Children->default[ i ]);
-
- //
- Console::Write( L"Removing the {0}.", childCodeGroup->Name );
- // Remove child code group.
-
- //
- codeGroup->RemoveChild( childCodeGroup );
- //
- }
- Console::WriteLine();
- }
- else
- {
- Console::Write( L"There are no child code groups" );
- Console::WriteLine( L" in this code group." );
- }
- }
-};
-
-int main()
-{
- Members::Main();
-}
-
-//
-// This sample produces the following output:
-//
-// The two code groups are equal.
-// Added a custom membership condition:
-//
-//
-//
-// Comparing the resolved code group with the initial code group.
-// The two code groups are not equal.
-//
-// *** System.Security.Policy.FileCodeGroup summary ***
-// A FileCodeGroup named with Union merge logic has been created with hash
-// code 113151473. This code group contains a Zone - Intranet membership
-// condition with the Same directory FileIO - NoAccess permission set. The
-// code group has the following security policy:
-// There are 1 child code groups in this code group.
-// Removing the Read-only group.
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp
deleted file mode 100644
index e8c9be6b48e..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/CPP/members.cpp
+++ /dev/null
@@ -1,359 +0,0 @@
-// This sample demonstrates how to use each member of the FirstMatchCodeGroup
-// class.
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Policy;
-using namespace System::Security::Permissions;
-using namespace System::Reflection;
-
-ref class Members
-{
-public:
- [STAThread]
- static void Main()
- {
- // Create a new FirstMatchCodeGroup.
- FirstMatchCodeGroup^ codeGroup = constructDefaultGroup();
-
- // Create a deep copy of the FirstMatchCodeGroup.
- //
- FirstMatchCodeGroup^ copyCodeGroup =
- dynamic_cast(codeGroup->Copy());
- //
-
- // Compare the original code group with the copy.
- CompareTwoCodeGroups( codeGroup, copyCodeGroup );
-
- addPolicy( &codeGroup );
- addXmlMember( &codeGroup );
- updateMembershipCondition( &codeGroup );
- addChildCodeGroup( &codeGroup );
-
- Console::Write( L"Comparing the resolved code group " );
- Console::WriteLine( L"with the initial code group." );
- FirstMatchCodeGroup^ resolvedCodeGroup =
- ResolveGroupToEvidence( codeGroup );
- if ( CompareTwoCodeGroups( codeGroup, resolvedCodeGroup ) )
- {
- PrintCodeGroup( resolvedCodeGroup );
- }
- else
- {
- PrintCodeGroup( codeGroup );
- }
-
- Console::WriteLine( L"This sample completed successfully; "
- L"press Enter to exit." );
- Console::ReadLine();
- }
-
-private:
- // Create a FirstMatchCodeGroup with an exclusive policy and membership
- // condition.
- static FirstMatchCodeGroup^ constructDefaultGroup()
- {
- // Construct a new FirstMatchCodeGroup with Read, Write, Append
- // and PathDiscovery access.
- // Create read access permission to the root directory on drive C.
- //
- FileIOPermission^ rootFilePermissions =
- gcnew FileIOPermission( PermissionState::None );
- rootFilePermissions->AllLocalFiles = FileIOPermissionAccess::Read;
- rootFilePermissions->SetPathList( FileIOPermissionAccess::Read, L"C:\\" );
-
- // Add a permission to a named permission set.
- NamedPermissionSet^ namedPermissions =
- gcnew NamedPermissionSet( L"RootPermissions" );
- namedPermissions->AddPermission( rootFilePermissions );
-
- // Create a PolicyStatement with exclusive rights to the policy.
- PolicyStatement^ policy = gcnew PolicyStatement(
- namedPermissions,PolicyStatementAttribute::Exclusive );
-
- // Create a FirstMatchCodeGroup with a membership condition that
- // matches all code, and an exclusive policy.
- FirstMatchCodeGroup^ codeGroup = gcnew FirstMatchCodeGroup(
- gcnew AllMembershipCondition,policy );
- //
-
- // Set the name of the first match code group.
- //
- codeGroup->Name = L"TempCodeGroup";
- //
-
- // Set the description of the first match code group.
- //
- codeGroup->Description = L"Temp folder permissions group";
- //
- return codeGroup;
- }
-
- // Add file permission to restrict write access to all files
- // on the local machine.
- static void addPolicy( interior_ptr codeGroup )
- {
- // Set the PolicyStatement property to a policy with read access to
- // the root directory on drive C.
- //
- FileIOPermission^ rootFilePermissions =
- gcnew FileIOPermission( PermissionState::None );
- rootFilePermissions->AllLocalFiles = FileIOPermissionAccess::Read;
- rootFilePermissions->SetPathList( FileIOPermissionAccess::Read, L"C:\\" );
-
- NamedPermissionSet^ namedPermissions =
- gcnew NamedPermissionSet( L"RootPermissions" );
- namedPermissions->AddPermission( rootFilePermissions );
-
- // Create a PolicyStatement with exclusive rights to the policy.
- PolicyStatement^ policy = gcnew PolicyStatement(
- namedPermissions,PolicyStatementAttribute::Exclusive );
- ( *codeGroup )->PolicyStatement = policy;
- //
- }
-
- // Set the membership condition of the code group.
- static void updateMembershipCondition(
- interior_ptr codeGroup )
- {
- // Set the membership condition of the specified FirstMatchCodeGroup
- // to the Intranet zone.
- //
- ZoneMembershipCondition^ zoneCondition =
- gcnew ZoneMembershipCondition( SecurityZone::Intranet );
- ( *codeGroup )->MembershipCondition = zoneCondition;
- //
- }
-
- // Create a child code group with read-access file permissions and add it
- // to the specified code group.
- static void addChildCodeGroup( interior_ptr codeGroup )
- {
- // Create a first match code group with read access.
- //
- FileIOPermission^ rootFilePermissions = gcnew FileIOPermission(
- PermissionState::None );
- rootFilePermissions->AllLocalFiles = FileIOPermissionAccess::Read;
- rootFilePermissions->SetPathList( FileIOPermissionAccess::Read, L"C:\\" );
-
- PermissionSet^ permissions = gcnew PermissionSet(
- PermissionState::Unrestricted );
- permissions->AddPermission( rootFilePermissions );
-
- FirstMatchCodeGroup^ tempFolderCodeGroup =
- gcnew FirstMatchCodeGroup( gcnew AllMembershipCondition,
- gcnew PolicyStatement( permissions ) );
-
- // Set the name of the child code group and add it to
- // the specified code group.
- tempFolderCodeGroup->Name = L"Read-only code group";
- ( *codeGroup )->AddChild( tempFolderCodeGroup );
- //
- }
-
- // Compare the two FirstMatchCodeGroups.
- static bool CompareTwoCodeGroups( FirstMatchCodeGroup^ firstCodeGroup,
- FirstMatchCodeGroup^ secondCodeGroup )
- {
- // Compare the two specified FirstMatchCodeGroups for equality.
- //
- if ( firstCodeGroup->Equals( secondCodeGroup ) )
- //
- {
- Console::WriteLine( L"The two code groups are equal." );
- return true;
- }
- else
- {
- Console::WriteLine( L"The two code groups are not equal." );
- return false;
- }
- }
-
- // Retrieve the resolved policy based on executing evidence found
- // in the specified code group.
- static String^ ResolveEvidence( CodeGroup^ codeGroup )
- {
- String^ policyString = L"None";
-
- // Resolve the policy based on the executing assembly's evidence.
- //
- Assembly^ assembly = Members::typeid->Assembly;
- Evidence^ executingEvidence = assembly->Evidence;
-
- PolicyStatement^ policy = codeGroup->Resolve( executingEvidence );
- //
-
- if ( policy != nullptr )
- {
- policyString = policy->ToString();
- }
-
- return policyString;
- }
-
- // Retrieve the resolved code group based on the evidence from the
- // specified code group.
- static FirstMatchCodeGroup^ ResolveGroupToEvidence(
- FirstMatchCodeGroup^ codeGroup )
- {
- // Resolve matching code groups to the executing assembly.
- //
- Assembly^ assembly = Members::typeid->Assembly;
- Evidence^ evidence = assembly->Evidence;
- CodeGroup^ resolvedCodeGroup =
- codeGroup->ResolveMatchingCodeGroups( evidence );
- //
-
- return dynamic_cast(resolvedCodeGroup);
- }
-
- // If a domain attribute is not found in the specified
- // FirstMatchCodeGroup, add a child XML element identifying a custom
- // membership condition.
- static void addXmlMember( interior_ptr codeGroup )
- {
- //
- SecurityElement^ xmlElement = ( *codeGroup )->ToXml();
- //
-
- SecurityElement^ rootElement = gcnew SecurityElement( L"CodeGroup" );
-
- if ( xmlElement->Attribute(L"domain") == nullptr )
- {
- //
- SecurityElement^ newElement = gcnew SecurityElement(
- L"CustomMembershipCondition" );
- newElement->AddAttribute( L"class", L"CustomMembershipCondition" );
- newElement->AddAttribute( L"version", L"1" );
- newElement->AddAttribute( L"domain", L"contoso.com" );
- rootElement->AddChild( newElement );
- ( *codeGroup )->FromXml( rootElement );
- //
- }
-
- Console::WriteLine( L"Added a custom membership condition:" );
- Console::WriteLine( rootElement );
- }
-
- // Print the properties of the specified code group to the console.
- static void PrintCodeGroup( CodeGroup^ codeGroup )
- {
- // Compare the type of the specified object with the
- // FirstMatchCodeGroup type.
- //
- if ( !codeGroup->GetType()->Equals( FirstMatchCodeGroup::typeid ) )
- //
- {
- throw gcnew ArgumentException( L"Expected the FirstMatchCodeGroup type." );
- }
-
- String^ codeGroupName = codeGroup->Name;
- String^ membershipCondition = codeGroup->MembershipCondition->ToString();
-
- //
- String^ permissionSetName = codeGroup->PermissionSetName;
- //
-
- //
- int hashCode = codeGroup->GetHashCode();
- //
-
- String^ mergeLogic = L"";
- //
- if ( codeGroup->MergeLogic->Equals( L"First Match" ) )
- //
- {
- mergeLogic = L"with first-match merge logic";
- }
-
- // Retrieve the class path for the FirstMatchCodeGroup.
- //
- String^ firstMatchGroupClass = codeGroup->ToString();
- //
-
- String^ attributeString = L"";
- // Retrieve the string representation of the FirstMatchCodeGroup's
- // attributes.
- //
- if ( codeGroup->AttributeString != nullptr )
- {
- attributeString = codeGroup->AttributeString;
- }
- //
-
- // Write a summary to the console window.
- Console::WriteLine( L"\n*** {0} summary ***", firstMatchGroupClass );
- Console::Write( L"A FirstMatchCodeGroup named " );
- Console::Write( L"{0}{1}", codeGroupName, mergeLogic );
- Console::Write( L" has been created with hash code({0}).", hashCode );
- Console::Write( L"\nThis code group contains a {0}", membershipCondition );
- Console::Write( L" membership condition with the " );
- Console::WriteLine( L"{0} permission set.", permissionSetName );
-
- Console::Write( L"The code group contains the following policy: " );
- Console::Write( ResolveEvidence( codeGroup ) );
- Console::Write( L"\nIt also contains the following attributes: " );
- Console::WriteLine( attributeString );
-
- int childCount = codeGroup->Children->Count;
- if ( childCount > 0 )
- {
- Console::Write( L"There are {0}", childCount );
- Console::WriteLine( L" child elements in the code group." );
-
- // Iterate through the child code groups to display their names
- // and then remove them from the specified code group.
- for ( int i = 0; i < childCount; i++ )
- {
- // Retrieve a child code group, which has been cast as a
- // FirstMatchCodeGroup type.
- //
- FirstMatchCodeGroup^ childCodeGroup =
- dynamic_cast(codeGroup->Children->default[ i ]);
- //
-
- Console::Write( L"Removing the {0}.", childCodeGroup->Name );
- // Remove the child code group.
- //
- codeGroup->RemoveChild( childCodeGroup );
- //
- }
- Console::WriteLine();
- }
- else
- {
- Console::WriteLine( L" No child code groups were found in this"
- L" code group." );
- }
- }
-};
-
-int main()
-{
- Members::Main();
-}
-//
-// This sample produces the following output:
-//
-// The two code groups are equal.
-// Added a custom membership condition:
-//
-//
-//
-//
-// Comparing the resolved code group with the initial code group.
-// The two code groups are not equal.
-//
-// *** System.Security.Policy.FirstMatchCodeGroup summary ***
-// A FirstMatchCodeGroup named with first-match merge logic has been created
-// with hash code(113151525).
-// This code group contains a Zone - Intranet membership condition with the
-// permission set. The code group contains the following policy:
-// It also contains the following attributes:
-// There are 1 child elements in the code group.
-// Removing the Read-only code group.
-// This sample completed successfully; press Enter to exit.
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp
deleted file mode 100644
index 0e0dece2b02..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Policy.Gac/CPP/gac.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-//
-using namespace System;
-using namespace System::Security::Policy;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-
-[STAThread]
-int main()
-{
-
- //
- GacInstalled ^ myGacInstalled = gcnew GacInstalled;
- //
-
- //
- array
-
- //
- GacInstalled ^ myGacInstalledCopy =
- dynamic_cast(myGacInstalled->Copy());
- bool result = myGacInstalled->Equals( myGacInstalledCopy );
- //
-
- //
- Console::WriteLine( "Hashcode = {0}", myGacInstalled->GetHashCode() );
- //
-
- //
- Console::WriteLine( myGacInstalled->ToString() );
- //
-}
-//
diff --git a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs b/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs
deleted file mode 100644
index 0ced5a65dd6..00000000000
--- a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermission.cs
+++ /dev/null
@@ -1,216 +0,0 @@
-#define debug
-//#define debug
-// This custom permission is intended only for the purposes of illustration.
-// The following code shows how to create a custom permission that inherits
-// from CodeAccessPermission. The code implements all required overrides.
-// A wildcard character ('*') is implemented for the Name property.
-using System;
-using System.Security;
-using System.Security.Permissions;
-using System.IO;
-using System.Security.Policy;
-using System.Collections;
-using System.Text;
-// Use the command line option '/keyfile' or appropriate project settings to sign this assembly.
-[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()]
-
-namespace MyPermission
-{
- [Serializable()] sealed public class NameIdPermission : CodeAccessPermission, IUnrestrictedPermission
- {
- private String m_Name;
- private bool m_Unrestricted;
-
- public NameIdPermission(String name)
- {
- m_Name = name;
- }
-
- public NameIdPermission(PermissionState state)
- {
- if (state == PermissionState.None)
- {
- m_Name = "";
- }
- else
- if (state == PermissionState.Unrestricted)
- {
- throw new ArgumentException("Unrestricted state is not allowed for identity permissions.");
- }
- else
- {
- throw new ArgumentException("Invalid permission state.");
- }
- }
-
- public String Name
- {
- set{m_Name = value;}
- get{ return m_Name;}
- }
- public override IPermission Copy()
- {
- string name = m_Name;
- return new NameIdPermission( name );
- }
-
- public bool IsUnrestricted()
- {
- // Always false, unrestricted state is not allowed.
- return m_Unrestricted;
- }
-
- private bool VerifyType(IPermission target)
- {
- return (target is NameIdPermission);
- }
-
- public override bool IsSubsetOf(IPermission target)
- {
-#if(debug)
- Console.WriteLine ("************* Entering IsSubsetOf *********************");
-#endif
- if (target == null)
- {
- Console.WriteLine ("IsSubsetOf: target == null");
- return false;
- }
-#if(debug)
-
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- try
- {
- NameIdPermission operand = ( NameIdPermission)target;
-
- // The following check for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if (true == operand.m_Unrestricted)
- {
- return true;
- }
- else if (true == this.m_Unrestricted)
- {
- return false;
- }
-
- if (this.m_Name != null)
- {
- if (operand.m_Name == null) return false;
-
- if (this.m_Name == "") return true;
- }
-
- if (this.m_Name.Equals (operand.m_Name))
- {
- return true;
- }
- else
- {
- // Check for wild card character '*'.
- int i = operand.m_Name.LastIndexOf ("*");
-
- if (i > 0)
- {
- string prefix = operand.m_Name.Substring (0, i);
-
- if (this.m_Name.StartsWith (prefix))
- {
- return true;
- }
- }
- }
-
- return false;
- }
- catch (InvalidCastException)
- {
- throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
- }
- }
-
- public override IPermission Intersect(IPermission target)
- {
- Console.WriteLine ("************* Entering Intersect *********************");
- if (target == null)
- {
- return null;
- }
-#if(debug)
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- if (!VerifyType(target))
- {
- throw new ArgumentException (String.Format ("Argument is wrong type.", this.GetType ().FullName));
- }
-
- NameIdPermission operand = ( NameIdPermission)target;
-
- if (operand.IsSubsetOf (this)) return operand.Copy ();
- else if (this.IsSubsetOf (operand)) return this.Copy ();
- else
- return null;
- }
-
- public override IPermission Union(IPermission target)
- {
-#if(debug)
- Console.WriteLine ("************* Entering Union *********************");
-#endif
- if (target == null)
- {
- return this;
- }
-#if(debug)
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- if (!VerifyType(target))
- {
- throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
- }
-
- NameIdPermission operand = ( NameIdPermission)target;
-
- if (operand.IsSubsetOf (this)) return this.Copy ();
- else if (this.IsSubsetOf (operand)) return operand.Copy ();
- else
- return null;
- }
-
- public override void FromXml(SecurityElement e)
- {
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- String elUnrestricted = e.Attribute("Unrestricted");
- if (null != elUnrestricted)
- {
- m_Unrestricted = bool.Parse(elUnrestricted);
- return;
- }
-
- String elName = e.Attribute( "Name" );
- m_Name = elName == null ? null : elName;
- }
-
- public override SecurityElement ToXml()
- {
- // Use the SecurityElement class to encode the permission to XML.
- SecurityElement esd = new SecurityElement("IPermission");
- String name = typeof( NameIdPermission).AssemblyQualifiedName;
- esd.AddAttribute("class", name);
- esd.AddAttribute("version", "1.0");
-
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if (m_Unrestricted)
- {
- esd.AddAttribute("Unrestricted", true.ToString());
- }
- if (m_Name != null) esd.AddAttribute( "Name", m_Name );
- return esd;
- }
- }
-}
diff --git a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermissionattribute.cs b/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermissionattribute.cs
deleted file mode 100644
index 73528122ef5..00000000000
--- a/snippets/csharp/System.Security.Permissions/CodeAccessSecurityAttribute/Overview/nameidpermissionattribute.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-//
-using System;
-using System.IO;
-using System.Runtime.Remoting;
-using System.Security;
-using System.Security.Permissions;
-using System.Reflection;
-using MyPermission;
-// Use the command line option '/keyfile' or appropriate project settings to sign this assembly.
-[assembly: System.Security.AllowPartiallyTrustedCallersAttribute ()]
-
-namespace MyPermissionAttribute
-{
- [AttributeUsage (AttributeTargets.Method | AttributeTargets.Constructor | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)]
- [Serializable]
- sealed public class NameIdPermissionAttribute : CodeAccessSecurityAttribute
- {
- private String m_Name = null;
- private bool m_unrestricted = false;
-
- public NameIdPermissionAttribute (SecurityAction action): base( action )
- {
- }
-
- public String Name
- {
- get { return m_Name; }
- set { m_Name = value; }
- }
-
- public override IPermission CreatePermission ()
- {
- if (m_unrestricted)
- {
- throw new ArgumentException ("Unrestricted permissions not allowed in identity permissions.");
- }
- else
- {
- if (m_Name == null)
- return new NameIdPermission (PermissionState.None);
-
- return new NameIdPermission (m_Name);
- }
- }
- }
-}
-//
\ No newline at end of file
diff --git a/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs b/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs
deleted file mode 100644
index 500ac1e23f1..00000000000
--- a/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/fileiopermission.cs
+++ /dev/null
@@ -1,514 +0,0 @@
-// This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml, FromXml,
-// GetPathList and SetPathList methods, and the AllFiles and AllLocalFiles properties
-// of the FileIOPermission class.
-//
-using System;
-using System.Security;
-using System.Security.Permissions;
-using System.Collections;
-
-[assembly: CLSCompliant(true)]
-
-public class FileIOPermissionDemo
-{
- // IsSubsetOf determines whether the current permission is a subset of the specified permission.
- // This method compares various FileIOPermission paths with FileIOPermissionAccess set to AllAccess.
- //
- private bool IsSubsetOfDemo()
- {
-
- bool returnValue = true;
-
- string fileIO1, fileIO2;
- FileIOPermission fileIOPerm1, fileIOPerm2;
-
- FileIOGenerator fileIOGen1 = new FileIOGenerator();
- FileIOGenerator fileIOGen2 = new FileIOGenerator();
-
- fileIOGen1.ResetIndex();
- while (fileIOGen1.CreateFilePath(out fileIO1 ))
- {
- if(fileIO1 == "")
- fileIOPerm1 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.AllAccess, fileIO1);
-
- Console.WriteLine("**********************************************************\n");
-
- fileIOGen2.ResetIndex();
-
- while (fileIOGen2.CreateFilePath(out fileIO2))
- {
- if (fileIO2 == "")
- fileIOPerm2 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm2 = new FileIOPermission(FileIOPermissionAccess.AllAccess, fileIO2);
- string firstPermission = fileIO1 == "" | fileIO1 == null ? "null" : fileIO1;
- string secondPermission = fileIO2 == "" | fileIO2 == null ? "null" : fileIO2;
- if (fileIOPerm2 == null) continue;
- try
- {
- if (fileIOPerm1.IsSubsetOf(fileIOPerm2))
- {
-
- Console.WriteLine(firstPermission + " is a subset of " + secondPermission + "\n");
- }
- else
- {
- Console.WriteLine(firstPermission + " is not a subset of " + secondPermission + "\n");
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("An exception was thrown for subset :" + fileIO1 == "" ? "null" : fileIO1 + "\n" +
- fileIO2 == "" ? "null" : fileIO2 + "\n" + e);
- }
- }
- }
- return returnValue;
- }
- //
-
- // Union creates a new permission that is the union of the current permission and the specified permission.
- //
- private bool UnionDemo()
- {
-
- bool returnValue = true;
-
- string fileIO1, fileIO2;
- FileIOPermission fileIOPerm1, fileIOPerm2;
- IPermission fileIOPerm3;
-
- FileIOGenerator fileIOGen1 = new FileIOGenerator();
- FileIOGenerator fileIOGen2 = new FileIOGenerator();
-
- fileIOGen1.ResetIndex();
- while (fileIOGen1.CreateFilePath( out fileIO1 ))
- {
- if (fileIO1 == "")
- fileIOPerm1 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO1);
- if (fileIO1 == null) continue;
-
- Console.WriteLine("**********************************************************\n");
- fileIOGen2.ResetIndex();
-
- while (fileIOGen2.CreateFilePath( out fileIO2 ))
- {
- if (fileIO2 == "")
- fileIOPerm2 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm2 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO2);
- try
- {
- string firstPermission = fileIO1 == "" | fileIO1 == null ? "null" : fileIO1;
- string secondPermission = fileIO2 == "" | fileIO2 == null ? "null" : fileIO2;
- fileIOPerm3 = (FileIOPermission)fileIOPerm1.Union(fileIOPerm2);
- fileIOPerm3 = fileIOPerm1.Union(fileIOPerm2);
-
- if (fileIOPerm3 == null)
- {
- Console.WriteLine("The union of " + firstPermission + " and " + secondPermission + " is null.");
- }
- else
- {
- Console.WriteLine("The union of " + firstPermission + " and " + secondPermission +
- " = \n\t" + ((FileIOPermission)fileIOPerm3).GetPathList(FileIOPermissionAccess.Read)[0]);
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("An exception was thrown for union " + e);
- returnValue = false;
- }
- }
- }
-
- return returnValue;
- }
- //
-
- // Intersect creates and returns a new permission that is the intersection of the current
- // permission and the permission specified.
- //
- private bool IntersectDemo()
- {
-
- bool returnValue = true;
-
- string fileIO1, fileIO2;
- FileIOPermission fileIOPerm1, fileIOPerm2, fileIOPerm3;
-
- FileIOGenerator fileIOGen1 = new FileIOGenerator();
- FileIOGenerator fileIOGen2 = new FileIOGenerator();
-
- fileIOGen1.ResetIndex();
- while (fileIOGen1.CreateFilePath(out fileIO1 ))
- {
- if (fileIO1 == "")
- fileIOPerm1 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO1);
-
- Console.WriteLine("**********************************************************\n");
- fileIOGen2.ResetIndex();
-
- while (fileIOGen2.CreateFilePath( out fileIO2 ))
- {
- if (fileIO2 == "")
- fileIOPerm2 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm2 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO2);
- string firstPermission = fileIO1 == "" | fileIO1 == null ? "null" : fileIO1;
- string secondPermission = fileIO2 == "" | fileIO2 == null ? "null" : fileIO2;
- try
- {
-
- fileIOPerm3 = (FileIOPermission)fileIOPerm1.Intersect(fileIOPerm2);
- if (fileIOPerm3 != null && fileIOPerm3.GetPathList(FileIOPermissionAccess.Read) != null)
- {
-
- Console.WriteLine("The intersection of " + firstPermission + " and \n\t" + secondPermission +
- " = \n\t" + ((FileIOPermission)fileIOPerm3).GetPathList(FileIOPermissionAccess.Read)[0]);
- }
- else
- {
- Console.WriteLine("The intersection of " + firstPermission + " and " + secondPermission + " is null.");
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("An exception was thrown for intersection " + e);
- returnValue = false;
- }
- }
- }
-
- return returnValue;
- }
- //
-
- //Copy creates and returns an identical copy of the current permission.
- //
- private bool CopyDemo()
- {
- bool returnValue = true;
- string fileIO1;
- FileIOPermission fileIOPerm1, fileIOPerm2;
- FileIOGenerator fileIOGen1 = new FileIOGenerator();
- FileIOGenerator fileIOGen2 = new FileIOGenerator();
-
- fileIOGen1.ResetIndex();
- while (fileIOGen1.CreateFilePath( out fileIO1 ))
- {
- if (fileIO1 == "")
- fileIOPerm1 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO1);
-
- Console.WriteLine("**********************************************************\n");
- fileIOGen2.ResetIndex();
- try
- {
- fileIOPerm2 = (FileIOPermission)fileIOPerm1.Copy();
- if (fileIOPerm2 != null)
- {
- Console.WriteLine("Result of copy = " + fileIOPerm2.ToString() + "\n");
- }
- else
- {
- Console.WriteLine("Result of copy is null. \n");
- }
- }
- catch (Exception e)
- {
- {
- if (fileIO1 == "")
- {
- Console.WriteLine("The target FileIOPermission is empty, copy failed.");
- }
- else
- {
- Console.WriteLine(e);
- }
- }
- continue;
- }
- }
- return returnValue;
- }
- //
-
- // ToXml creates an XML encoding of the permission and its current state;
- // FromXml reconstructs a permission with the specified state from the XML encoding.
- //
- private bool ToFromXmlDemo()
- {
-
- bool returnValue = true;
-
- string fileIO1;
- FileIOPermission fileIOPerm1, fileIOPerm2;
-
- FileIOGenerator fileIOGen1 = new FileIOGenerator();
- FileIOGenerator fileIOGen2 = new FileIOGenerator();
-
- fileIOGen1.ResetIndex();
- while (fileIOGen1.CreateFilePath( out fileIO1 ))
- {
- if (fileIO1 == "")
- fileIOPerm1 = new FileIOPermission(PermissionState.None);
- else
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.Read, fileIO1);
-
- Console.WriteLine("********************************************************\n");
- fileIOGen2.ResetIndex();
- try
- {
- fileIOPerm2 = new FileIOPermission(PermissionState.None);
- fileIOPerm2.FromXml(fileIOPerm1.ToXml());
- Console.WriteLine("Result of ToFromXml = " + fileIOPerm2.ToString() + "\n");
- }
- catch (Exception e)
- {
- Console.WriteLine("ToFromXml failed :" + fileIOPerm1.ToString() + e);
- continue;
- }
- }
-
- return returnValue;
- }
- //
-
- // AddPathList adds access for the specified files and directories to the existing state of the permission.
- // SetPathList sets the specified access to the specified files and directories, replacing the existing state
- // of the permission.
- // GetPathList gets all files and directories that have the specified FileIOPermissionAccess.
- //
- private bool SetGetPathListDemo()
- {
- try
- {
- Console.WriteLine("********************************************************\n");
-
- FileIOPermission fileIOPerm1;
- Console.WriteLine("Creating a FileIOPermission with AllAccess rights for 'C:\\Examples\\Test\\TestFile.txt");
- //
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\\Examples\\Test\\TestFile.txt");
- //
- Console.WriteLine("Adding 'C:\\Temp' to the write access list, and \n 'C:\\Examples\\Test' to read access.");
- fileIOPerm1.AddPathList(FileIOPermissionAccess.Write, "C:\\Temp");
- fileIOPerm1.AddPathList(FileIOPermissionAccess.Read, "C:\\Examples\\Test");
- string[] paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read);
- Console.WriteLine("Read access before SetPathList = ");
- foreach (string path in paths)
- {
- Console.WriteLine("\t" + path);
- }
- Console.WriteLine("Setting the read access list to \n'C:\\Temp'");
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\\Temp");
- paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read);
- Console.WriteLine("Read access list after SetPathList = ");
- foreach (string path in paths)
- {
- Console.WriteLine("\t" + path);
- }
-
- paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Write);
- Console.WriteLine("Write access list after SetPathList = ");
- foreach (string path in paths)
- {
- Console.WriteLine("\t" + path);
- }
-
- Console.WriteLine("Write access = \n" +
- fileIOPerm1.GetPathList(FileIOPermissionAccess.AllAccess));
- }
- catch (ArgumentException e)
- {
- // FileIOPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
- Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. "
- + "This property cannot be used as a parameter in GetPathList "
- + "because it represents more than one type of file variable access. : \n" + e);
- }
-
- return true;
- }
- //
-
- // The AllFiles property gets or sets the permitted access to all files.
- // The AllLocalFiles property gets or sets the permitted access to all local files.
- //
- private bool AllFilesDemo()
- {
- try
- {
- Console.WriteLine("********************************************************\n");
-
- FileIOPermission fileIOPerm1;
- Console.WriteLine("Creating a FileIOPermission and adding read access for all files");
- fileIOPerm1 = new FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\\Examples\\Test\\TestFile.txt");
- fileIOPerm1.AllFiles = FileIOPermissionAccess.Read;
- Console.WriteLine("AllFiles access = " + fileIOPerm1.AllFiles);
- Console.WriteLine("Adding AllAccess rights for local files.");
- fileIOPerm1.AllLocalFiles = FileIOPermissionAccess.AllAccess;
- Console.WriteLine("AllLocalFiles access = " + fileIOPerm1.AllLocalFiles);
- }
- catch (ArgumentException e)
- {
- Console.WriteLine(e);
- return false;
- }
-
- return true;
- }
- //
-
- // Invoke all demos.
- public bool RunDemo()
- {
-
- bool ret = true;
- bool retTmp;
- // Call the IsSubsetOfPath demo.
- if (retTmp = IsSubsetOfDemo()) Console.Out.WriteLine("IsSubsetOf demo completed successfully.");
- else Console.Out.WriteLine("IsSubsetOf demo failed.");
- ret = retTmp && ret;
-
- // Call the Union demo.
- if (retTmp = UnionDemo()) Console.Out.WriteLine("Union demo completed successfully.");
- else Console.Out.WriteLine("Union demo failed.");
- ret = retTmp && ret;
-
- // Call the Intersect demo.
- if (retTmp = IntersectDemo()) Console.Out.WriteLine("Intersect demo completed successfully.");
- else Console.Out.WriteLine("Intersect demo failed.");
- ret = retTmp && ret;
-
- // Call the Copy demo.
- if (retTmp = CopyDemo()) Console.Out.WriteLine("Copy demo completed successfully.");
- else Console.Out.WriteLine("Copy demo failed.");
- ret = retTmp && ret;
-
- // Call the ToFromXml demo.
- if (retTmp = ToFromXmlDemo()) Console.Out.WriteLine("ToFromXml demo completed successfully.");
- else Console.Out.WriteLine("ToFromXml demo failed.");
- ret = retTmp && ret;
-
- // Call the SetGetPathList demo.
- if (retTmp = SetGetPathListDemo()) Console.Out.WriteLine("SetGetPathList demo completed successfully.");
- else Console.Out.WriteLine("SetGetPathList demo failed.");
- ret = retTmp && ret;
-
- // Call the AllFiles demo.
- if (retTmp = AllFilesDemo()) Console.Out.WriteLine("AllFiles demo completed successfully.");
- else Console.Out.WriteLine("AllFiles demo failed.");
- ret = retTmp && ret;
-
- return (ret);
- }
- // Test harness.
- public static void Main(String[] args)
- {
- try
- {
- FileIOPermissionDemo democase = new FileIOPermissionDemo();
- bool ret = democase.RunDemo();
- if (ret)
- {
- Console.Out.WriteLine("FileIOPermission demo completed successfully.");
- Console.Out.WriteLine("Press the Enter key to exit.");
- string consoleInput = Console.ReadLine();
- System.Environment.ExitCode = 100;
- }
- else
- {
- Console.Out.WriteLine("FileIOPermission demo failed.");
- Console.Out.WriteLine("Press the Enter key to exit.");
- string consoleInput = Console.ReadLine();
- System.Environment.ExitCode = 101;
- }
- }
- catch (Exception e)
- {
- Console.Out.WriteLine("FileIOPermission demo failed");
- Console.WriteLine(e.ToString());
- Console.Out.WriteLine("Press the Enter key to exit.");
- string consoleInput = Console.ReadLine();
- System.Environment.ExitCode = 101;
- }
- }
-}
-
-// This class generates FileIOPermission objects.
-
-internal class FileIOGenerator
-{
-
- private string[] myFile =
-{
- "C:\\Examples\\Test\\TestFile.txt",
- "C:\\Examples\\Test\\",
- "C:\\Examples\\Test\\..",
- "C:\\Temp"
-};
-
- private FileIOPermissionAccess[] myAccess =
-{
- FileIOPermissionAccess.AllAccess,
- FileIOPermissionAccess.Append,
- FileIOPermissionAccess.NoAccess,
- FileIOPermissionAccess.PathDiscovery,
- FileIOPermissionAccess.Read,
- FileIOPermissionAccess.Write
-};
-
- private int fileIndex = 0;
-
- public FileIOGenerator()
- {
-
- ResetIndex();
- }
-
- public void ResetIndex()
- {
- fileIndex = 0;
- }
-
- // Create a file path string.
- //
- public bool CreateFilePath( out string file )
- {
-
- if (fileIndex == myFile.Length)
- {
-
- file = "";
- fileIndex++;
- return true;
- }
- if (fileIndex > myFile.Length)
- {
- file = "";
- return false;
- }
-
- file = myFile[fileIndex++];
-
- try
- {
- return true;
- }
- catch (Exception e)
- {
- Console.WriteLine("Cannot create FileIOPermission: " + file + " " + e);
- file = "";
- return true;
- }
- }
- //
-}
-//
diff --git a/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs b/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs
deleted file mode 100644
index 746d997cbdb..00000000000
--- a/snippets/csharp/System.Security.Permissions/FileIOPermission/GetPathList/remarks.cs
+++ /dev/null
@@ -1,97 +0,0 @@
-using System;
-using System.Security;
-using System.Security.Permissions;
-
-public class FileIOPermissionDemo
-{
- public static void Main()
- {
- try
- {
- FileIOPermission fileIOPerm1;
- fileIOPerm1 = new FileIOPermission(PermissionState.Unrestricted);
-
- // Tests for: SetPathList(FileIOPermissionAccess,String)
-
- // Test the Read list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\\documents");
-
- Console.WriteLine("Read access before SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Read))
- {
- Console.WriteLine("\t" + path);
- }
-
- //
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\\temp");
- //
-
- Console.WriteLine("Read access after SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Read))
- {
- Console.WriteLine("\t" + path);
- }
-
- // Test the Write list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, "C:\\temp");
-
- Console.WriteLine("Write access before SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Write))
- {
- Console.WriteLine("\t" + path);
- }
- //
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, "C:\\documents");
- //
-
- Console.WriteLine("Write access after SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Write))
- {
- Console.WriteLine("\t" + path);
- }
-
- // Tests for: SetPathList(FileIOPermissionAccess,String[])
-
- // Test the Read list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, new string[] {"C:\\pictures", "C:\\music"});
-
- Console.WriteLine("Read access before SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Read))
- {
- Console.WriteLine("\t" + path);
- }
-
- //
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, new string[] {"C:\\temp", "C:\\Documents"});
- //
-
- Console.WriteLine("Read access after SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Read))
- {
- Console.WriteLine("\t" + path);
- }
-
- // Test the Write list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, new string[] {"C:\\temp", "C:\\Documents"});
-
- Console.WriteLine("Write access before SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Write))
- {
- Console.WriteLine("\t" + path);
- }
- //
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, new string[] {"C:\\pictures", "C:\\music"});
- //
-
- Console.WriteLine("Write access after SetPathList = ");
- foreach (string path in fileIOPerm1.GetPathList(FileIOPermissionAccess.Write))
- {
- Console.WriteLine("\t" + path);
- }
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
-}
diff --git a/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs b/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs
deleted file mode 100644
index 6247bb2012b..00000000000
--- a/snippets/csharp/System.Security/CodeAccessPermission/Overview/nameidpermission.cs
+++ /dev/null
@@ -1,240 +0,0 @@
-#define debug
-//
-//#define debug
-// This custom permission is intended only for the purposes of illustration.
-// The following code shows how to create a custom permission that inherits
-// from CodeAccessPermission. The code implements all required overrides.
-// A wildcard character ('*') is implemented for the Name property.
-using System;
-using System.Security;
-using System.Security.Permissions;
-using System.IO;
-using System.Security.Policy;
-using System.Collections;
-using System.Text;
-
-[assembly:System.Reflection.AssemblyKeyFile("Key.snk")]
-[assembly:System.Security.AllowPartiallyTrustedCallersAttribute()]
-
-namespace MyPermission
-{
- [Serializable()] sealed public class NameIdPermission : CodeAccessPermission, IUnrestrictedPermission
- {
- private String m_Name;
- private bool m_Unrestricted;
-
- public NameIdPermission(String name)
- {
- m_Name = name;
- }
-
- public NameIdPermission(PermissionState state)
- {
- if (state == PermissionState.None)
- {
- m_Name = "";
- }
- else
- if (state == PermissionState.Unrestricted)
- {
- throw new ArgumentException("Unrestricted state is not allowed for identity permissions.");
- }
- else
- {
- throw new ArgumentException("Invalid permission state.");
- }
- }
-
- public String Name
- {
- set{m_Name = value;}
- get{ return m_Name;}
- }
- //
- public override IPermission Copy()
- {
- string name = m_Name;
- return new NameIdPermission( name );
- }
- //
- //
- public bool IsUnrestricted()
- {
- // Always false, unrestricted state is not allowed.
- return m_Unrestricted;
- }
- //
-
- private bool VerifyType(IPermission target)
- {
- return (target is NameIdPermission);
- }
- //
- public override bool IsSubsetOf(IPermission target)
- {
-#if(debug)
- Console.WriteLine ("************* Entering IsSubsetOf *********************");
-#endif
- if (target == null)
- {
- Console.WriteLine ("IsSubsetOf: target == null");
- return false;
- }
-#if(debug)
-
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- try
- {
- NameIdPermission operand = ( NameIdPermission)target;
-
- // The following check for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if (true == operand.m_Unrestricted)
- {
- return true;
- }
- else if (true == this.m_Unrestricted)
- {
- return false;
- }
-
- if (this.m_Name != null)
- {
- if (operand.m_Name == null) return false;
-
- if (this.m_Name == "") return true;
- }
-
- if (this.m_Name.Equals (operand.m_Name))
- {
- return true;
- }
- else
- {
- // Check for wild card character '*'.
- int i = operand.m_Name.LastIndexOf ("*");
-
- if (i > 0)
- {
- string prefix = operand.m_Name.Substring (0, i);
-
- if (this.m_Name.StartsWith (prefix))
- {
- return true;
- }
- }
- }
-
- return false;
- }
- catch (InvalidCastException)
- {
- throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
- }
- }
- //
- //
- public override IPermission Intersect(IPermission target)
- {
- Console.WriteLine ("************* Entering Intersect *********************");
- if (target == null)
- {
- return null;
- }
-#if(debug)
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- if (!VerifyType(target))
- {
- throw new ArgumentException (String.Format ("Argument is wrong type.", this.GetType ().FullName));
- }
-
- NameIdPermission operand = ( NameIdPermission)target;
-
- if (operand.IsSubsetOf (this)) return operand.Copy ();
- else if (this.IsSubsetOf (operand)) return this.Copy ();
- else
- return null;
- }
- //
-
- //
- public override IPermission Union(IPermission target)
- {
-#if(debug)
- Console.WriteLine ("************* Entering Union *********************");
-#endif
- if (target == null)
- {
- return this;
- }
-#if(debug)
- Console.WriteLine ("This is = " + (( NameIdPermission)this).Name);
- Console.WriteLine ("Target is " + (( NameIdPermission)target).m_Name);
-#endif
- if (!VerifyType(target))
- {
- throw new ArgumentException (String.Format ("Argument_WrongType", this.GetType ().FullName));
- }
-
- NameIdPermission operand = ( NameIdPermission)target;
-
- if (operand.IsSubsetOf (this)) return this.Copy ();
- else if (this.IsSubsetOf (operand)) return operand.Copy ();
- else
- return null;
- }
- //
- //
-
- //
- //
-
- //
- //
-
- //
- //
-
- //
- //
- public override void FromXml(SecurityElement e)
- {
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- String elUnrestricted = e.Attribute("Unrestricted");
- if (null != elUnrestricted)
- {
- m_Unrestricted = bool.Parse(elUnrestricted);
- return;
- }
-
- String elName = e.Attribute( "Name" );
- m_Name = elName == null ? null : elName;
- }
- //
- //
- public override SecurityElement ToXml()
- {
- // Use the SecurityElement class to encode the permission to XML.
- SecurityElement esd = new SecurityElement("IPermission");
- String name = typeof( NameIdPermission).AssemblyQualifiedName;
- esd.AddAttribute("class", name);
- esd.AddAttribute("version", "1.0");
-
- // The following code for unrestricted permission is only included as an example for
- // permissions that allow the unrestricted state. It is of no value for this permission.
- if (m_Unrestricted)
- {
- esd.AddAttribute("Unrestricted", true.ToString());
- }
- if (m_Name != null) esd.AddAttribute( "Name", m_Name );
- return esd;
- }
- //
- }
-}
-//
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb
deleted file mode 100644
index 9d2fe556440..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.PermissionSet/VB/permissionset.vb
+++ /dev/null
@@ -1,138 +0,0 @@
-'
-' This sample demonstrates the use of the PermissionSet class.
-Imports System.Reflection
-Imports System.Security.Permissions
-Imports System.Security
-Imports System.IO
-Imports System.Collections
-
-Class [MyClass]
-
- Public Shared Sub PermissionSetDemo()
- Console.WriteLine("Executing PermissionSetDemo")
- Try
- '
- ' Open a new PermissionSet.
- Dim ps1 As New PermissionSet(PermissionState.None)
- Console.WriteLine("Adding permission to open a file from a file dialog box.")
- '
- ' Add a permission to the permission set.
- ps1.AddPermission(New FileDialogPermission(FileDialogPermissionAccess.Open))
- '
- Console.WriteLine("Demanding permission to open a file.")
- ps1.Demand()
- Console.WriteLine("Demand succeeded.")
- '
- Console.WriteLine("Adding permission to save a file from a file dialog box.")
- ps1.AddPermission(New FileDialogPermission(FileDialogPermissionAccess.Save))
- Console.WriteLine("Demanding permission to open and save a file.")
- ps1.Demand()
- Console.WriteLine("Demand succeeded.")
- Console.WriteLine("Adding permission to read environment variable USERNAME.")
- ps1.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"))
- ps1.Demand()
- Console.WriteLine("Demand succeeded.")
- Console.WriteLine("Adding permission to read environment variable COMPUTERNAME.")
- ps1.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Read, "COMPUTERNAME"))
- '
- ' Demand all the permissions in the set.
- Console.WriteLine("Demand all permissions.")
- ps1.Demand()
- '
- Console.WriteLine("Demand succeeded.")
- '
- ' Display the number of permissions in the set.
- Console.WriteLine("Number of permissions = " & ps1.Count)
- '
- '
- ' Display the value of the IsSynchronized property.
- Console.WriteLine("IsSynchronized property = " & ps1.IsSynchronized)
- '
- '
- ' Display the value of the IsReadOnly property.
- Console.WriteLine("IsReadOnly property = " & ps1.IsReadOnly)
- '
- '
- ' Display the value of the SyncRoot property.
- Console.WriteLine("SyncRoot property = " & CType(ps1.SyncRoot, PermissionSet).ToString())
- '
- '
- ' Display the result of a call to the ContainsNonCodeAccessPermissions method.
- ' Gets a value indicating whether the PermissionSet contains permissions
- ' that are not derived from CodeAccessPermission.
- ' Returns true if the PermissionSet contains permissions that are not
- ' derived from CodeAccessPermission; otherwise, false.
- Console.WriteLine("ContainsNonCodeAccessPermissions method returned " & ps1.ContainsNonCodeAccessPermissions())
- '
- '
- Console.WriteLine("Value of the permission set ToString = " & ControlChars.Lf & ps1.ToString())
- '
- Dim ps2 As New PermissionSet(PermissionState.None)
- '
- ' Create a second permission set and compare it to the first permission set.
- ps2.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Read, "USERNAME"))
- ps2.AddPermission(New EnvironmentPermission(EnvironmentPermissionAccess.Write, "COMPUTERNAME"))
- Console.WriteLine("Permissions in first permission set:")
- Dim list As IEnumerator = ps1.GetEnumerator()
- While list.MoveNext()
- Console.WriteLine(list.Current.ToString())
- End While
- Console.WriteLine("Second permission IsSubsetOf first permission = " & ps2.IsSubsetOf(ps1))
- '
- '
- ' Display the intersection of two permission sets.
- Dim ps3 As PermissionSet = ps2.Intersect(ps1)
- Console.WriteLine("The intersection of the first permission set and " & "the second permission set = " & ps3.ToString())
- '
- ' Create a new permission set.
- Dim ps4 As New PermissionSet(PermissionState.None)
- ps4.AddPermission(New FileIOPermission(FileIOPermissionAccess.Read, "C:\Temp\Testfile.txt"))
- ps4.AddPermission(New FileIOPermission(FileIOPermissionAccess.Read Or FileIOPermissionAccess.Write Or FileIOPermissionAccess.Append, "C:\Temp\Testfile.txt"))
- '
- ' Display the union of two permission sets.
- Dim ps5 As PermissionSet = ps3.Union(ps4)
- Console.WriteLine("The union of permission set 3 and permission set 4 = " & ps5.ToString())
- '
- '
- ' Remove FileIOPermission from the permission set.
- ps5.RemovePermission(GetType(FileIOPermission))
- Console.WriteLine("The last permission set after removing FileIOPermission = " & ps5.ToString())
- '
- '
- ' Change the permission set using SetPermission.
- ps5.SetPermission(New EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "USERNAME"))
- Console.WriteLine("Permission set after SetPermission = " & ps5.ToString())
- '
- '
- ' Display result of ToXml and FromXml operations.
- Dim ps6 As New PermissionSet(PermissionState.None)
- ps6.FromXml(ps5.ToXml())
- Console.WriteLine("Result of ToFromXml = " & ps6.ToString() & ControlChars.Lf)
- '
- '
- ' Display results of PermissionSet.GetEnumerator.
- Dim psEnumerator As IEnumerator = ps1.GetEnumerator()
- While psEnumerator.MoveNext()
- Console.WriteLine(psEnumerator.Current)
- End While
- '
- '
- ' Check for an unrestricted permission set.
- Dim ps7 As New PermissionSet(PermissionState.Unrestricted)
- Console.WriteLine("Permission set is unrestricted = " & ps7.IsUnrestricted())
- '
- '
- ' Create and display a copy of a permission set.
- ps7 = ps5.Copy()
- Console.WriteLine("Result of copy = " & ps7.ToString())
- '
- Catch e As Exception
- Console.WriteLine(e.Message.ToString())
- End Try
- End Sub
-
- Overloads Shared Sub Main(ByVal args() As String)
- PermissionSetDemo()
- End Sub
-End Class
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/VB/nameidpermissionattribute.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/VB/nameidpermissionattribute.vb
deleted file mode 100644
index bb5269089df..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.CodeAccessSecurityAttribute/VB/nameidpermissionattribute.vb
+++ /dev/null
@@ -1,45 +0,0 @@
-'
-Imports System.IO
-Imports System.Runtime.Remoting
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Reflection
-Imports MyPermission
-
-' Use the command line option '/keyfile' or appropriate project settings to sign this assembly.
-
-Namespace MyPermissionAttribute
-
- Public NotInheritable Class NameIdPermissionAttribute
- Inherits CodeAccessSecurityAttribute
- Private m_Name As String = Nothing
- Private m_unrestricted As Boolean = False
-
-
- Public Sub New(ByVal action As SecurityAction)
- MyBase.New(action)
- End Sub
-
-
- Public Property Name() As String
- Get
- Return m_name
- End Get
- Set(ByVal Value As String)
- m_name = Value
- End Set
- End Property
-
- Public Overrides Function CreatePermission() As IPermission
- If m_unrestricted Then
- Throw New ArgumentException("Unrestricted permissions not allowed in identity permissions.")
- Else
- If m_name Is Nothing Then
- Return New NameIdPermission(PermissionState.None)
- End If
- Return New NameIdPermission(m_name)
- End If
- End Function 'CreatePermission
- End Class
-End Namespace
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb
deleted file mode 100644
index ea368b0b998..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.DataProtectionPermission2/VB/dataprotect.vb
+++ /dev/null
@@ -1,172 +0,0 @@
-'
-Imports System.Security.Permissions
-Imports System.Security.Cryptography
-Imports System.Security
-Imports System.IO
-
-
-
-Public Class DataProtect
- ' Create a byte array for additional entropy when using the
- ' Protect and Unprotect methods.
- Private Shared s_additionalEntropy As Byte() = {9, 8, 7, 6, 5}
-
- Private Shared encryptedSecret() As Byte
- Private Shared originalData() As Byte
-
- Public Shared Sub Main(ByVal args() As String)
- '
- Console.WriteLine("Creating a permission with the Flags property =" + " ProtectData.")
- Dim sp As New DataProtectionPermission(DataProtectionPermissionFlags.ProtectData)
- sp.PermitOnly()
- '
- ' Protect the data
- ProtectData()
- ' This should fail without the correct permission
- UnprotectData()
- ' Revert the permission that limited access
- CodeAccessPermission.RevertPermitOnly()
-
- ' This should now work.
- UnprotectData()
- ' Demonstrate the behavior of the class members.
- ShowMembers()
-
- Console.WriteLine("Press the Enter key to exit.")
- Console.ReadKey()
- Return
-
- End Sub
-
-
- ' The following method is intended to demonstrate only the behavior of
- ' DataProtectionPermission class members,and not their practical usage.
- ' Most properties and methods in this class are used for the resolution
- ' and enforcement of security policy by the security infrastructure code.
- Private Shared Sub ShowMembers()
- Console.WriteLine("Creating four DataProtectionPermissions")
- Console.WriteLine("Creating the first permission with the Flags " + "property = ProtectData.")
- Dim sp1 As New DataProtectionPermission(DataProtectionPermissionFlags.ProtectData)
-
- Console.WriteLine("Creating the second permission with the Flags " + "property = AllFlags.")
-
- Dim sp2 As New DataProtectionPermission(DataProtectionPermissionFlags.AllFlags)
-
- Console.WriteLine("Creating the third permission with a permission " + "state = Unrestricted.")
- '
- Dim sp3 As New DataProtectionPermission(PermissionState.Unrestricted)
- '
- Console.WriteLine("Creating the fourth permission with a permission" + " state = None.")
-
- Dim sp4 As New DataProtectionPermission(PermissionState.None)
- '
- Dim rc As Boolean = sp2.IsSubsetOf(sp3)
- Console.WriteLine("Is the permission with all flags set (AllFlags) " + "a subset of " + vbLf + " " + vbTab + "the permission with an Unrestricted " + "permission state? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
- rc = sp1.IsSubsetOf(sp2)
- Console.WriteLine("Is the permission with ProtectData access a " + "subset of the permission with " + vbLf + vbTab + "AllFlags set? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
- '
- '
- rc = sp3.IsUnrestricted()
- Console.WriteLine("Is the third permission unrestricted? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
- '
- '
- Console.WriteLine("Copying the second permission to the fourth " + "permission.")
- sp4 = CType(sp2.Copy(), DataProtectionPermission)
- rc = sp4.Equals(sp2)
- Console.WriteLine("Is the fourth permission equal to the second " + "permission? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
- '
- '
- Console.WriteLine("Creating the intersection of the second and " + "first permissions.")
- sp4 = CType(sp2.Intersect(sp1), DataProtectionPermission)
- Console.WriteLine("The value of the Flags property is: " + sp4.Flags.ToString())
- '
- '
- Console.WriteLine("Creating the union of the second and first " + "permissions.")
- sp4 = CType(sp2.Union(sp1), DataProtectionPermission)
- Console.WriteLine("Result of the union of the second permission with the first: " + sp4.Flags.ToString())
- '
- '
- Console.WriteLine("Using an XML round trip to reset the fourth " + "permission.")
- sp4.FromXml(sp2.ToXml())
- rc = sp4.Equals(sp2)
- Console.WriteLine("Does the XML round trip result equal the " + "original permission? " + IIf(rc, "Yes", "No")) 'TODO: For performance reasons this should be changed to nested IF statements
-
- End Sub
-
- '
-
- ' Create a simple byte array containing data to be encrypted.
- Public Shared Sub ProtectData()
- Dim secret As Byte() = {0, 1, 2, 3, 4, 1, 2, 3, 4}
-
- 'Encrypt the data.
- encryptedSecret = Protect(secret)
- Console.WriteLine("The encrypted byte array is:")
- If Not (encryptedSecret Is Nothing) Then
- PrintValues(encryptedSecret)
- End If
-
- End Sub
-
-
- ' Decrypt the data and store in a byte array.
- Public Shared Sub UnprotectData()
- originalData = Unprotect(encryptedSecret)
- If Not (originalData Is Nothing) Then
- Console.WriteLine(vbCr + vbLf + "The original data is:")
- PrintValues(originalData)
- End If
-
- End Sub
-
-
- ' Encrypt data in the specified byte array.
- Public Shared Function Protect(ByVal data() As Byte) As Byte()
- Try
- ' Encrypt the data using DataProtectionScope.CurrentUser.
- ' The result can be decrypted only by the user who encrypted
- ' the data.
- Return ProtectedData.Protect(data, s_additionalEntropy, DataProtectionScope.CurrentUser)
- Catch e As CryptographicException
- Console.WriteLine("Data was not encrypted. " + "An error has occurred.")
- Console.WriteLine(e.ToString())
- Return Nothing
- Catch e As SecurityException
- Console.WriteLine("Insufficient permissions. " + "An error has occurred.")
- Console.WriteLine(e.ToString())
- Return Nothing
- End Try
-
- End Function 'Protect
-
-
- ' Decrypt data in the specified byte array.
- Public Shared Function Unprotect(ByVal data() As Byte) As Byte()
- Try
- 'Decrypt the data using DataProtectionScope.CurrentUser.
- Return ProtectedData.Unprotect(data, s_additionalEntropy, DataProtectionScope.CurrentUser)
- Catch e As CryptographicException
- Console.WriteLine("Data was not decrypted. " + "An error has occurred.")
- Console.WriteLine(e.ToString())
- Return Nothing
- Catch e As SecurityException
- Console.WriteLine("Insufficient permissions. " + "An error has occurred.")
- Console.WriteLine(e.ToString())
- Return Nothing
- End Try
-
- End Function 'Unprotect
-
-
- Public Shared Sub PrintValues(ByVal myArr() As [Byte])
- Dim i As [Byte]
- For Each i In myArr
- Console.Write(vbTab + "{0}", i)
- Next i
- Console.WriteLine()
-
- End Sub
-End Class
-
-
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb
deleted file mode 100644
index 962fd946c9d..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.EnvironmentPermission/VB/environmentpermission.vb
+++ /dev/null
@@ -1,258 +0,0 @@
- ' This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml and FromXml methods
-' of the EnvironmentPermission class.
-'
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Collections
-
-
-Public Class EnvironmentPermissionDemo
-
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- '
- Private Function IsSubsetOfDemo() As Boolean
- Dim returnValue As Boolean = True
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "windir")
- Dim envPerm2 As New EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "TEMP")
- If envPerm1.IsSubsetOf(envPerm2) Then
-
- Console.WriteLine("'windir' is a subset of 'TEMP'" + vbLf)
- Else
- Console.WriteLine("windir" + " is not a subset of " + "TEMP" + vbLf)
- End If
- envPerm1.SetPathList(EnvironmentPermissionAccess.Read, "TEMP")
-
- If envPerm1.IsSubsetOf(envPerm2) Then
-
- Console.WriteLine("Read access is a subset of AllAccess" + vbLf)
- Else
- Console.WriteLine("Read access is not a subset of AllAccess" + vbLf)
- End If
-
- Return returnValue
-
- End Function 'IsSubsetOfDemo
-
- '
- ' Union creates a new permission that is the union of the current permission and the specified permission.
- '
- Private Function UnionDemo() As Boolean
- Dim returnValue As Boolean = True
- Dim envIdPerm3 As IPermission
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "windir")
- Dim envPerm2 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "TEMP")
- envIdPerm3 = CType(envPerm1.Union(envPerm2), EnvironmentPermission)
- envIdPerm3 = envPerm1.Union(envPerm2)
- Console.WriteLine("The union of 'windir' and 'TEMP'" + " = " + _
- CType(envIdPerm3, EnvironmentPermission).GetPathList(EnvironmentPermissionAccess.Read).ToString())
-
- Return returnValue
-
- End Function 'UnionDemo
-
- '
- ' Intersect creates and returns a new permission that is the intersection of
- ' the current permission and the permission specified.
- '
- Private Function IntersectDemo() As Boolean
-
- Dim envIdPerm3 As IPermission
- Dim returnValue As Boolean = True
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "windir")
- Dim envPerm2 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "TEMP")
- Try
- envIdPerm3 = CType(envPerm1.Intersect(envPerm2), EnvironmentPermission)
- If Not (envIdPerm3 Is Nothing) AndAlso Not (CType(envIdPerm3, _
- EnvironmentPermission).GetPathList(EnvironmentPermissionAccess.Read) Is Nothing) Then
- Console.WriteLine("The intersection of " + "windir" + " and " + "TEMP" + _
- " = " + CType(envIdPerm3, EnvironmentPermission).GetPathList(EnvironmentPermissionAccess.Read).ToString())
- Else
- Console.WriteLine("The intersection of " + "windir" + " and " + "TEMP" + " is null.")
- End If
- Catch e As Exception
- Console.WriteLine("An exception was thrown for intersection : " + e.Message)
- returnValue = False
- End Try
-
- Return returnValue
-
- End Function 'IntersectDemo
-
- '
- 'Copy creates and returns an identical copy of the current permission.
- '
- Private Function CopyDemo() As Boolean
- Dim returnValue As Boolean = True
- '
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "windir")
- '
- Try
- Dim envPerm2 As EnvironmentPermission = CType(envPerm1.Copy(), EnvironmentPermission)
- If Not (envPerm2 Is Nothing) Then
- Console.WriteLine("Result of copy = " + envPerm2.ToString() + vbLf)
- Else
- Console.WriteLine("Result of copy is null. " + vbLf)
- End If
- Catch e As Exception
- Console.WriteLine(e)
- End Try
-
- Return returnValue
-
- End Function 'CopyDemo
-
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs
- ' a permission with the specified state from the XML encoding.
- '
- Private Function ToFromXmlDemo() As Boolean
- Dim returnValue As Boolean = True
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.Read, "windir")
- Dim envPerm2 As New EnvironmentPermission(PermissionState.None)
- envPerm2.FromXml(envPerm1.ToXml())
- Console.WriteLine("Result of ToFromXml = " + envPerm2.ToString() + vbLf)
-
- Return returnValue
-
- End Function 'ToFromXmlDemo
-
- '
- ' AddPathList adds access for the specified environment variables to the existing state of the permission.
- ' SetPathList Sets the specified access to the specified environment variables to the existing state
- ' of the permission.
- ' GetPathList gets all environment variables with the specified EnvironmentPermissionAccess.
- '
- Private Function SetGetPathListDemo() As Boolean
- Try
- Console.WriteLine("********************************************************" + vbLf)
- '
- Console.WriteLine("Creating an EnvironmentPermission with AllAccess rights for 'TMP'")
- Dim envPerm1 As New EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "TMP")
- '
- Console.WriteLine("Adding 'TEMP' to the write access list, and 'windir' to the read access list.")
- envPerm1.AddPathList(EnvironmentPermissionAccess.Write, "TEMP")
- envPerm1.AddPathList(EnvironmentPermissionAccess.Read, "windir")
- Console.WriteLine("Read access list before SetPathList = " + envPerm1.GetPathList(EnvironmentPermissionAccess.Read))
- Console.WriteLine("Setting read access to 'TMP'")
- envPerm1.SetPathList(EnvironmentPermissionAccess.Read, "TMP")
- Console.WriteLine("Read access list after SetPathList = " + envPerm1.GetPathList(EnvironmentPermissionAccess.Read))
- Console.WriteLine("Write access list = " + envPerm1.GetPathList(EnvironmentPermissionAccess.Write))
- Console.WriteLine("Write access environment variables = " + envPerm1.GetPathList(EnvironmentPermissionAccess.AllAccess))
- Catch e As ArgumentException
- ' EnvironmentPermissionAccess.AllAccess cannot be used as a parameter for GetPathList.
- Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. " + _
- " This property cannot be used as a parameter in GetPathList, because it represents " + _
- "more than one type of environment variable : " + vbLf + e.Message)
- End Try
-
- Return True
-
- End Function 'SetGetPathListDemo
-
- '
- ' Invoke all demos.
- Public Function RunDemo() As Boolean
-
- Dim ret As Boolean = True
- Dim retTmp As Boolean
- ' Call IsSubsetOf demo.
- retTmp = IsSubsetOfDemo()
- If retTmp Then
-
- Console.Out.WriteLine("IsSubset demo completed successfully.")
- Else
- Console.Out.WriteLine("IsSubset demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call Union demo.
- retTmp = UnionDemo()
- If retTmp Then
-
- Console.Out.WriteLine("Union demo completed successfully.")
- Else
- Console.Out.WriteLine("Union demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call Intersect demo.
- retTmp = IntersectDemo()
- If retTmp Then
-
- Console.Out.WriteLine("Intersect demo completed successfully.")
- Else
- Console.Out.WriteLine("Intersect demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
-
-
- ' Call Copy demo.
- retTmp = CopyDemo()
- If retTmp Then
-
- Console.Out.WriteLine("Copy demo completed successfully.")
- Else
- Console.Out.WriteLine("Copy demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call ToFromXml demo.
- retTmp = ToFromXmlDemo()
- If retTmp Then
-
- Console.Out.WriteLine("ToFromXml demo completed successfully.")
- Else
- Console.Out.WriteLine("ToFromXml demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call SetGetPathList demo.
- retTmp = SetGetPathListDemo()
- If retTmp Then
-
- Console.Out.WriteLine("SetGetPathList demo completed successfully.")
- Else
- Console.Out.WriteLine("SetGetPathList demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- Return ret
-
- End Function 'RunDemo
-
- ' Test harness.
- Public Shared Sub Main(ByVal args() As String)
- Try
- Dim democase As New EnvironmentPermissionDemo()
- Dim ret As Boolean = democase.RunDemo()
- If ret Then
- Console.Out.WriteLine("EnvironmentPermission demo completed successfully.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 100
- Else
- Console.Out.WriteLine("EnvironmentPermission demo failed.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End If
- Catch e As Exception
- Console.Out.WriteLine("EnvironmentPermission demo failed.")
- Console.WriteLine(e.ToString())
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End Try
-
- End Sub
-End Class
-
-
-
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb
deleted file mode 100644
index 922ca7d0195..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/fileiopermission.vb
+++ /dev/null
@@ -1,480 +0,0 @@
-' This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml, FromXml,
-' GetPathList and SetPathList methods, and the AllFiles and AllLocalFiles properties
-' of the FileIOPermission class.
-'
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Collections
-
-
-
-Public Class FileIOPermissionDemo
-
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- ' This method compares various FileIOPermission paths with FileIOPermissionAccess set to AllAccess.
- '
- Private Function IsSubsetOfDemo() As Boolean
-
- Dim returnValue As Boolean = True
- Dim fileIO1 As String = ""
- Dim fileIO2 As String = ""
- Dim fileIOPerm1, fileIOPerm2 As FileIOPermission
-
- Dim fileIOGen1 As New FileIOGenerator()
- Dim fileIOGen2 As New FileIOGenerator()
-
- fileIOGen1.ResetIndex()
- While fileIOGen1.CreateFilePath(fileIO1)
- If fileIO1 = "" Then
- fileIOPerm1 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, fileIO1)
- End If
-
- Console.WriteLine("**********************************************************" & ControlChars.Lf)
-
- fileIOGen2.ResetIndex()
-
- While fileIOGen2.CreateFilePath(fileIO2)
- If fileIO2 = "" Then
- fileIOPerm2 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm2 = New FileIOPermission(FileIOPermissionAccess.AllAccess, fileIO2)
- End If
- Dim firstPermission As String = IIf(fileIO1 = "" Or fileIO1 Is Nothing, "null", fileIO1)
- Dim secondPermission As String = IIf(fileIO2 = "" Or fileIO2 Is Nothing, "null", fileIO2)
- If fileIOPerm2 Is Nothing Then
- Continue While
- End If
- Try
- If fileIOPerm1.IsSubsetOf(fileIOPerm2) Then
-
- Console.WriteLine((firstPermission & " is a subset of " & secondPermission & ControlChars.Lf))
- Else
- Console.WriteLine((firstPermission & " is not a subset of " & secondPermission & ControlChars.Lf))
- End If
-
- Catch e As Exception
- Console.WriteLine(IIf("An exception was thrown for subset :" & fileIO1 = "", "null", IIf(fileIO1 & ControlChars.Lf & fileIO2 = "", "null", fileIO2 & ControlChars.Lf & e.ToString())))
- End Try
-
- End While
-
- End While
- Return returnValue
- End Function 'IsSubsetOfDemo
- '
-
- ' Union creates a new permission that is the union of the current permission and the specified permission.
- '
- Private Function UnionDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim fileIO1 As String = ""
- Dim fileIO2 As String = ""
- Dim fileIOPerm1, fileIOPerm2 As FileIOPermission
- Dim fileIOPerm3 As IPermission
-
- Dim fileIOGen1 As New FileIOGenerator()
- Dim fileIOGen2 As New FileIOGenerator()
-
- fileIOGen1.ResetIndex()
- While fileIOGen1.CreateFilePath(fileIO1)
- If fileIO1 = "" Then
- fileIOPerm1 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO1)
- End If
- Console.WriteLine("**********************************************************" & ControlChars.Lf)
- fileIOGen2.ResetIndex()
-
- While fileIOGen2.CreateFilePath(fileIO2)
-
- Try
- If fileIO2 = "" Then
- fileIOPerm2 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm2 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO2)
- End If
- Dim firstPermission As String = IIf(fileIO1 = "" Or fileIO1 Is Nothing, "null", fileIO1)
- Dim secondPermission As String = IIf(fileIO2 = "" Or fileIO2 Is Nothing, "null", fileIO2)
- fileIOPerm3 = CType(fileIOPerm1.Union(fileIOPerm2), FileIOPermission)
- fileIOPerm3 = fileIOPerm1.Union(fileIOPerm2)
-
- If fileIOPerm3 Is Nothing Then
- Console.WriteLine(("The union of " & firstPermission & " and " & secondPermission & " is null."))
- Else
- Console.WriteLine(("The union of " & firstPermission & " and " & secondPermission & " = " & ControlChars.Lf & ControlChars.Tab & CType(fileIOPerm3, FileIOPermission).GetPathList(FileIOPermissionAccess.Read)(0)))
- End If
- Catch e As Exception
- Console.WriteLine(("An exception was thrown for union " & e.ToString()))
- returnValue = False
- End Try
-
- End While
-
- End While
-
-
- Return returnValue
- End Function 'UnionDemo
- '
-
- ' Intersect creates and returns a new permission that is the intersection of the current
- ' permission and the permission specified.
- '
- Private Function IntersectDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim fileIO1 As String = ""
- Dim fileIO2 As String = ""
- Dim fileIOPerm1, fileIOPerm2, fileIOPerm3 As FileIOPermission
-
- Dim fileIOGen1 As New FileIOGenerator()
- Dim fileIOGen2 As New FileIOGenerator()
-
- fileIOGen1.ResetIndex()
- While fileIOGen1.CreateFilePath(fileIO1)
- If fileIO1 = "" Then
- fileIOPerm1 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO1)
- End If
- Console.WriteLine("**********************************************************" & ControlChars.Lf)
- fileIOGen2.ResetIndex()
-
- While fileIOGen2.CreateFilePath(fileIO2)
- If fileIO2 = "" Then
- fileIOPerm2 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm2 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO2)
- End If
- Dim firstPermission As String = IIf(fileIO1 = "" Or fileIO1 Is Nothing, "null", fileIO1)
- Dim secondPermission As String = IIf(fileIO2 = "" Or fileIO2 Is Nothing, "null", fileIO2)
- Try
-
- fileIOPerm3 = CType(fileIOPerm1.Intersect(fileIOPerm2), FileIOPermission)
- If Not (fileIOPerm3 Is Nothing) AndAlso Not (fileIOPerm3.GetPathList(FileIOPermissionAccess.Read) Is Nothing) Then
-
- Console.WriteLine(("The intersection of " & firstPermission & " and " & ControlChars.Lf & ControlChars.Tab & secondPermission & " = " & ControlChars.Lf & ControlChars.Tab & CType(fileIOPerm3, FileIOPermission).GetPathList(FileIOPermissionAccess.Read)(0)))
- Else
- Console.WriteLine(("The intersection of " & firstPermission & " and " & secondPermission & " is null."))
- End If
- Catch e As Exception
- Console.WriteLine(("An exception was thrown for intersection " & e.ToString()))
- returnValue = False
- End Try
-
- End While
-
- End While
-
- Return returnValue
- End Function 'IntersectDemo
- '
-
- 'Copy creates and returns an identical copy of the current permission.
- '
- Private Function CopyDemo() As Boolean
- Dim returnValue As Boolean = True
- Dim fileIO1 As String = ""
- Dim fileIOPerm1, fileIOPerm2 As FileIOPermission
- Dim fileIOGen1 As New FileIOGenerator()
- Dim fileIOGen2 As New FileIOGenerator()
-
- fileIOGen1.ResetIndex()
- While fileIOGen1.CreateFilePath(fileIO1)
- If fileIO1 = "" Then
- fileIOPerm1 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO1)
- End If
- Console.WriteLine("**********************************************************" & ControlChars.Lf)
- fileIOGen2.ResetIndex()
- Try
- fileIOPerm2 = CType(fileIOPerm1.Copy(), FileIOPermission)
- If Not (fileIOPerm2 Is Nothing) Then
- Console.WriteLine(("Result of copy = " & fileIOPerm2.ToString() & ControlChars.Lf))
- Else
- Console.WriteLine("Result of copy is null. " & ControlChars.Lf)
- End If
- Catch e As Exception
- If (True.ToString()) Then
- If fileIO1 = "" Then
- Console.WriteLine("The target FileIOPermission is empty, copy failed.")
-
- Else
- Console.WriteLine(e.ToString())
- End If
- End If
- Continue While
- End Try
-
- End While
- Return returnValue
- End Function 'CopyDemo
- '
-
- ' ToXml creates an XML encoding of the permission and its current state;
- ' FromXml reconstructs a permission with the specified state from the XML encoding.
- '
- Private Function ToFromXmlDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim fileIO1 As String = ""
- Dim fileIOPerm1, fileIOPerm2 As FileIOPermission
-
- Dim fileIOGen1 As New FileIOGenerator()
- Dim fileIOGen2 As New FileIOGenerator()
-
- fileIOGen1.ResetIndex()
- While fileIOGen1.CreateFilePath(fileIO1)
- If fileIO1 = "" Then
- fileIOPerm1 = New FileIOPermission(PermissionState.None)
- Else
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.Read, fileIO1)
- End If
- Console.WriteLine("********************************************************" & ControlChars.Lf)
- fileIOGen2.ResetIndex()
- Try
- fileIOPerm2 = New FileIOPermission(PermissionState.None)
- fileIOPerm2.FromXml(fileIOPerm1.ToXml())
- Console.WriteLine(("Result of ToFromXml = " & fileIOPerm2.ToString() & ControlChars.Lf))
-
- Catch e As Exception
- Console.WriteLine(("ToFromXml failed :" & fileIOPerm1.ToString() & e.ToString()))
- Continue While
- End Try
-
- End While
-
- Return returnValue
- End Function 'ToFromXmlDemo
- '
-
- ' AddPathList adds access for the specified files and directories to the existing state of the permission.
- ' SetPathList sets the specified access to the specified files and directories, replacing the existing state
- ' of the permission.
- ' GetPathList gets all files and directories that have the specified FileIOPermissionAccess.
- '
- Private Function SetGetPathListDemo() As Boolean
- Try
- Console.WriteLine("********************************************************" & ControlChars.Lf)
-
- Dim fileIOPerm1 As FileIOPermission
- Console.WriteLine("Creating a FileIOPermission with AllAccess rights for 'C:\Examples\Test\TestFile.txt")
- '
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\Examples\Test\TestFile.txt")
- '
- Console.WriteLine("Adding 'C:\Temp' to the write access list, and " & ControlChars.Lf & " 'C:\Examples\Test' to read access.")
- fileIOPerm1.AddPathList(FileIOPermissionAccess.Write, "C:\Temp")
- fileIOPerm1.AddPathList(FileIOPermissionAccess.Read, "C:\Examples\Test")
- Dim paths As String() = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine("Read access before SetPathList = ")
- Dim path As String
- For Each path In paths
- Console.WriteLine((ControlChars.Tab & path))
- Next path
- Console.WriteLine("Setting the read access list to " & ControlChars.Lf & "'C:\Temp'")
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\Temp")
- paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine("Read access list after SetPathList = ")
- For Each path In paths
- Console.WriteLine((ControlChars.Tab & path))
- Next path
-
- paths = fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
- Console.WriteLine("Write access list after SetPathList = ")
- For Each path In paths
- Console.WriteLine((ControlChars.Tab & path))
- Next path
-
- Dim pathList() As String
- pathList = fileIOPerm1.GetPathList(FileIOPermissionAccess.AllAccess)
-
- Catch e As ArgumentException
- ' FileIOPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
- Console.WriteLine(("An ArgumentException occurred as a result of using AllAccess. " & "This property cannot be used as a parameter in GetPathList " & "because it represents more than one type of file variable access. : " & ControlChars.Lf & e.ToString()))
- End Try
-
- Return True
- End Function 'SetGetPathListDemo
- '
-
- ' The AllFiles property gets or sets the permitted access to all files.
- ' The AllLocalFiles property gets or sets the permitted access to all local files.
- '
- Private Function AllFilesDemo() As Boolean
- Try
- Console.WriteLine("********************************************************" & ControlChars.Lf)
-
- Dim fileIOPerm1 As FileIOPermission
- Console.WriteLine("Creating a FileIOPermission and adding read access for all files")
- fileIOPerm1 = New FileIOPermission(FileIOPermissionAccess.AllAccess, "C:\Examples\Test\TestFile.txt")
- fileIOPerm1.AllFiles = FileIOPermissionAccess.Read
- Console.WriteLine("AllFiles access = " & fileIOPerm1.AllFiles.ToString())
- Console.WriteLine("Adding AllAccess rights for local files.")
- fileIOPerm1.AllLocalFiles = FileIOPermissionAccess.AllAccess
- Console.WriteLine("AllLocalFiles access = " & fileIOPerm1.AllLocalFiles.ToString())
-
- Catch e As ArgumentException
- Console.WriteLine(e.ToString())
- Return False
- End Try
-
- Return True
- End Function 'AllFilesDemo
- '
-
- ' Invoke all demos.
- Public Function RunDemo() As Boolean
-
- Dim ret As Boolean = True
- Dim retTmp As Boolean
- ' Call the IsSubsetOfPath demo.
- retTmp = IsSubsetOfDemo()
- If retTmp Then
- Console.Out.WriteLine("IsSubsetOf demo completed successfully.")
- Else
- Console.Out.WriteLine("IsSubsetOf demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the Union demo.
- retTmp = UnionDemo()
- If retTmp Then
- Console.Out.WriteLine("Union demo completed successfully.")
- Else
- Console.Out.WriteLine("Union demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the Intersect demo.
- retTmp = IntersectDemo()
- If retTmp Then
- Console.Out.WriteLine("Intersect demo completed successfully.")
- Else
- Console.Out.WriteLine("Intersect demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call the Copy demo.
- retTmp = CopyDemo()
- If retTmp Then
- Console.Out.WriteLine("Copy demo completed successfully.")
- Else
- Console.Out.WriteLine("Copy demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the ToFromXml demo.
- retTmp = ToFromXmlDemo()
- If retTmp Then
- Console.Out.WriteLine("ToFromXml demo completed successfully.")
- Else
- Console.Out.WriteLine("ToFromXml demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the SetGetPathList demo.
- retTmp = SetGetPathListDemo()
- If retTmp Then
- Console.Out.WriteLine("SetGetPathList demo completed successfully.")
- Else
- Console.Out.WriteLine("SetGetPathList demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the AllFiles demo.
- retTmp = AllFilesDemo()
- If retTmp Then
- Console.Out.WriteLine("AllFiles demo completed successfully.")
- Else
- Console.Out.WriteLine("AllFiles demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- Return ret
- End Function 'RunDemo
-
- ' Test harness.
- Public Overloads Shared Sub Main(ByVal args() As [String])
- Try
- Dim democase As New FileIOPermissionDemo()
- Dim ret As Boolean = democase.RunDemo()
- If ret Then
- Console.Out.WriteLine("FileIOPermission demo completed successfully.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 100
- Else
- Console.Out.WriteLine("FileIOPermission demo failed.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End If
- Catch e As Exception
- Console.Out.WriteLine("FileIOPermission demo failed")
- Console.WriteLine(e.ToString())
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End Try
- End Sub
-End Class
-
-
-' This class generates FileIOPermission objects.
-
-Friend Class FileIOGenerator
-
-
- Private myFile As String() = {"C:\Examples\Test\TestFile.txt", "C:\Examples\Test\", "C:\Examples\Test\..", "C:\Temp"}
-
- Private myAccess As FileIOPermissionAccess() = {FileIOPermissionAccess.AllAccess, FileIOPermissionAccess.Append, FileIOPermissionAccess.NoAccess, FileIOPermissionAccess.PathDiscovery, FileIOPermissionAccess.Read, FileIOPermissionAccess.Write}
-
- Private fileIndex As Integer = 0
-
-
- Public Sub New()
-
- ResetIndex()
- End Sub
-
-
- Public Sub ResetIndex()
- fileIndex = 0
- End Sub
-
- ' Create a file path.
- '
- Public Function CreateFilePath(ByRef file As String) As Boolean
-
- If fileIndex = myFile.Length Then
- file = ""
- fileIndex &= 1
- Return True
- End If
- If fileIndex > myFile.Length Then
- file = ""
- Return False
- End If
-
- file = myFile(fileIndex)
- fileIndex = fileIndex + 1
-
- Try
- Return True
- Catch e As Exception
- Console.WriteLine(("Cannot create FileIOPermission: " & file & " " & e.ToString()))
- file = ""
- Return True
- End Try
- End Function
- '
-End Class
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb
deleted file mode 100644
index c2bbdcddc02..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermission/VB/remarks.vb
+++ /dev/null
@@ -1,87 +0,0 @@
-
-Imports System.Security
-Imports System.Security.Permissions
-
-Public Class FileIOPermissionDemo
- Public Shared Sub Main()
- Try
- Dim fileIOPerm1 as New FileIOPermission(PermissionState.Unrestricted)
-
- ' Tests for: SetPathList(FileIOPermissionAccess,String)
-
- ' Test the Read list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\\documents")
-
- Console.WriteLine("Read access before SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine(" " + path)
- Next path
-
- '
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, "C:\\temp")
- '
-
- Console.WriteLine("Read access after SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine(" " + path)
- Next path
-
-
- ' Test the Write list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, "C:\\temp")
-
- Console.WriteLine("Write access before SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
- Console.WriteLine(" " + path)
- Next path
-
- '
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, "C:\\documents")
- '
-
- Console.WriteLine("Write access after SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
- Console.WriteLine(" " + path)
- Next path
-
- ' Tests for: SetPathList(FileIOPermissionAccess,String[])
-
- ' Test the Read list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, New String() {"C:\\pictures", "C:\\music"})
-
- Console.WriteLine("Read access before SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine(" " + path)
- Next path
-
- '
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Read, New String() {"C:\\temp", "C:\\Documents"})
- '
-
- Console.WriteLine("Read access after SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Read)
- Console.WriteLine(" " + path)
- Next path
-
-
- ' Test the Write list
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, New String() {"C:\\temp", "C:\\Documents"})
-
- Console.WriteLine("Write access before SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
- Console.WriteLine(" " + path)
- Next path
- '
- fileIOPerm1.SetPathList(FileIOPermissionAccess.Write, New String() {"C:\\pictures", "C:\\music"})
- '
-
- Console.WriteLine("Write access after SetPathList = ")
- For Each path In fileIOPerm1.GetPathList(FileIOPermissionAccess.Write)
- Console.WriteLine(" " + path)
- Next path
-
- Catch ex As Exception
- Console.WriteLine(ex.Message)
- End Try
- End Sub
-End Class
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb
deleted file mode 100644
index 0178540000a..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.FileIOPermissionAttribute/VB/fileiopermissionattribute.vb
+++ /dev/null
@@ -1,84 +0,0 @@
-'
-' This sample demonstrates the use of the FileIOPermissionAttribute class.
-' The sample follows the recommended procedure of first granting PermitOnly permissions,
-' then using a Deny on that set of granted permissions.
-Imports System.Reflection
-Imports System.Security.Permissions
-Imports System.Security
-Imports System.IO
-
-Class [MyClass]
-
-
- ' This method demonstrates the use of the FileIOPermissionAttribute to create a PermitOnly permission.
- '
- '
- '
- '
- '
- '
- ' Set the Read, PathDiscovery, Append, Write, and All properties.
- _
- Public Shared Sub PermitOnlyMethod()
- '
- '
- '
- '
- '
- Console.WriteLine("Executing PermitOnlyMethod.")
- Console.WriteLine("PermitOnly the Read permission for drive C.")
- Console.WriteLine("PermitOnly the PathDiscovery permission for " & ControlChars.Lf & ControlChars.Tab & "C:\Documents and Settings\All Users.")
- Console.WriteLine("PermitOnly the Append permission for " & ControlChars.Lf & ControlChars.Tab & "C:\Documents and Settings\All Users\Application Data.")
- Console.WriteLine("PermitOnly the Write permission for " & ControlChars.Lf & ControlChars.Tab & "C:\Documents and Settings\All Users\Application Data\Microsoft.")
- Console.WriteLine("PermitOnly the All permission for " & ControlChars.Lf & ControlChars.Tab & "C:\Documents and Settings\All Users\Application Data\Microsoft\Network.")
-
- PermitOnlyTestMethod()
- End Sub
- '
-
-
- Public Shared Sub PermitOnlyTestMethod()
- Console.WriteLine("Executing PermitOnlyTestMethod.")
- Try
- Dim ps As New PermissionSet(PermissionState.None)
- ps.AddPermission(New FileIOPermission(FileIOPermissionAccess.Write, "C:\Documents and Settings\All Users\Application Data\Microsoft\Network\SomeFile"))
- Console.WriteLine(("Demanding permission to write " & "'C:\Documents and Settings\All Users\Application Data\Microsoft\Network\SomeFile'"))
- ps.Demand()
- Console.WriteLine("Demand succeeded.")
- ps.AddPermission(New FileIOPermission(FileIOPermissionAccess.Write, "C:\"))
- Console.WriteLine("Demanding permission to write to drive C.")
-
- ' This demand should cause an exception.
- ps.Demand()
- ' The TestFailed method is called if an exception is not thrown.
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("An exception was thrown because of a write demand: " & e.Message))
- End Try
- End Sub
-
-
- Public Shared Sub TestFailed()
- Console.WriteLine("Executing TestFailed.")
- Console.WriteLine("Throwing an exception.")
- Throw New Exception()
- End Sub
-
- Overloads Shared Sub Main(ByVal args() As String)
- Try
- PermitOnlyMethod()
- Catch e As Exception
- Console.WriteLine(e.Message.ToString())
- End Try
- End Sub
-End Class
-
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb
deleted file mode 100644
index ff70437a2f0..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermission/VB/gacidentitypermission.vb
+++ /dev/null
@@ -1,214 +0,0 @@
-'
-Imports System.Security
-Imports System.Security.Permissions
-
-Public Class GacIdentityPermissionDemo
-
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Function IsSubsetOfDemo() As Boolean
- Try
- '
- Dim Gac1 As New GacIdentityPermission
- Dim Gac2 As New GacIdentityPermission(PermissionState.None)
- If (Gac1.Equals(Gac2)) Then
- Console.WriteLine("GacIdentityPermission() equals GacIdentityPermission(PermissionState.None).")
- End If
- '
- If Gac1.IsSubsetOf(Gac2) Then
- Console.WriteLine((Gac1.ToString() & " is a subset of " & Gac2.ToString()))
- Else
- Console.WriteLine((Gac1.ToString() & " is not a subset of " & Gac2.ToString()))
- End If
- Catch e As Exception
- Console.WriteLine(("An exception was thrown : " & e.ToString().ToString()))
- Return False
- End Try
- Return True
- End Function 'IsSubsetOfDemo
-
- '
- '
- ' Union creates a new permission that is the union of the current permission
- ' and the specified permission.
- Private Function UnionDemo() As Boolean
- '
- Dim Gac1 As New GacIdentityPermission(PermissionState.None)
- '
- '
- Dim Gac2 As New GacIdentityPermission
- '
- Try
- Dim p3 As GacIdentityPermission = CType(Gac1.Union(Gac2), GacIdentityPermission)
-
- If Not (p3 Is Nothing) Then
- Console.WriteLine("The union of two GacIdentityPermissions was successful.")
-
- Else
- Console.WriteLine("The union of two GacIdentityPermissions failed.")
- Return False
- End If
- Catch e As Exception
- Console.WriteLine(("An exception was thrown : " & e.ToString()))
- Return False
- End Try
-
- Return True
- End Function 'UnionDemo
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the
- ' current permission and the specified permission.
- Private Function IntersectDemo() As Boolean
- Dim Gac1 As New GacIdentityPermission
- Dim Gac2 As New GacIdentityPermission
- Try
- Dim p3 As GacIdentityPermission = CType(Gac1.Intersect(Gac2), GacIdentityPermission)
- If Not (p3 Is Nothing) Then
- Console.WriteLine(("The intersection of the two permissions = " & p3.ToString() & ControlChars.Lf))
-
- Else
- Console.WriteLine("The intersection of the two permissions is null." & ControlChars.Lf)
- End If
- Catch e As Exception
- Console.WriteLine(("An exception was thrown : " & e.ToString()))
- Return False
- End Try
-
- Return True
- End Function 'IntersectDemo
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Function CopyDemo() As Boolean
-
- Dim Gac1 As New GacIdentityPermission
- Dim Gac2 As New GacIdentityPermission
- Console.WriteLine("**************************************************************************")
- Try
- Gac2 = CType(Gac1.Copy(), GacIdentityPermission)
- If Not (Gac2 Is Nothing) Then
- Console.WriteLine(("Result of copy = " & Gac2.ToString() & ControlChars.Lf))
- End If
-
- Catch e As Exception
- Console.WriteLine(("Copy failed : " & Gac1.ToString() & e.ToString()))
- Return False
- End Try
-
- Return True
- End Function 'CopyDemo
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
- ' permission with the specified state from the XML encoding.
- Private Function ToFromXmlDemo() As Boolean
- Dim Gac1 As New GacIdentityPermission
- Dim Gac2 As New GacIdentityPermission
- Console.WriteLine("**************************************************************************")
- Try
- Gac2 = New GacIdentityPermission(PermissionState.None)
- Gac2.FromXml(Gac1.ToXml())
- Dim result As Boolean = Gac2.Equals(Gac1)
- If Gac2.IsSubsetOf(Gac1) AndAlso Gac1.IsSubsetOf(Gac2) Then
- Console.WriteLine(("Result of ToFromXml = " & Gac2.ToString()))
- Else
- Console.WriteLine(Gac2.ToString())
- Console.WriteLine(Gac1.ToString())
- Return False
- End If
- Catch e As Exception
- Console.WriteLine(("ToFromXml failed. " & e.ToString()))
- Return False
- End Try
-
- Return True
- End Function 'ToFromXmlDemo
-
- '
- ' Invoke all demos.
- Public Function RunDemo() As Boolean
-
- Dim returnCode As Boolean = True
- Dim tempReturnCode As Boolean
- ' Call the IsSubsetOf demo.
- tempReturnCode = IsSubsetOfDemo()
- If tempReturnCode Then
- Console.Out.WriteLine("IsSubsetOf demo completed successfully.")
- Else
- Console.Out.WriteLine("Subset demo failed.")
- End If
- returnCode = tempReturnCode AndAlso returnCode
-
- ' Call the Union demo.
- tempReturnCode = UnionDemo()
- If tempReturnCode Then
- Console.Out.WriteLine("Union demo completed successfully.")
- Else
- Console.Out.WriteLine("Union demo failed.")
- End If
- returnCode = tempReturnCode AndAlso returnCode
-
- ' Call the Intersect demo.
- tempReturnCode = IntersectDemo()
- If tempReturnCode Then
- Console.Out.WriteLine("Intersect demo completed successfully.")
- Else
- Console.Out.WriteLine("Intersect demo failed.")
- End If
- returnCode = tempReturnCode AndAlso returnCode
-
-
- ' Call the Copy demo.
- tempReturnCode = CopyDemo()
- If tempReturnCode Then
- Console.Out.WriteLine("Copy demo completed successfully.")
- Else
- Console.Out.WriteLine("Copy demo failed.")
- End If
- returnCode = tempReturnCode AndAlso returnCode
-
- ' Call the ToFromXML demo.
- tempReturnCode = ToFromXmlDemo()
- If tempReturnCode Then
- Console.Out.WriteLine("ToFromXML demo completed successfully.")
- Else
- Console.Out.WriteLine("ToFromXml demo failed.")
- End If
- returnCode = tempReturnCode AndAlso returnCode
-
- Return returnCode
- End Function 'RunDemo
-
- ' Test harness.
- Public Overloads Shared Sub Main(ByVal args() As [String])
- Try
- Dim testcase As New GACIdentityPermissionDemo
- Dim returnCode As Boolean = testcase.RunDemo()
- If returnCode Then
- Console.Out.WriteLine("The GacIdentityPermission demo completed successfully.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 100
- Else
- Console.Out.WriteLine("The GacIdentityPermission demo failed.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End If
- Catch e As Exception
- Console.Out.WriteLine("The GacIdentityPermission demo failed.")
- Console.WriteLine(e.ToString())
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End Try
- End Sub
-End Class
-
-
-
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb
deleted file mode 100644
index bd335bbca31..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.GacIdentityPermissionAttribute/VB/gacidentitypermissionattribute.vb
+++ /dev/null
@@ -1,40 +0,0 @@
-'
-' To run this sample you must create a strong-name key named snkey.snk
-' using the Strong Name tool (sn.exe). Both the library assembly and the
-' application assembly that calls it must be signed with that key.
-' To run successfully, the application assembly must be in the global
-' assembly cache.
-' This console application can be created using the following code.
-
-'Imports System.Security
-'Imports System.Security.Policy
-'Imports System.Security.Principal
-'Imports System.Security.Permissions
-'Imports ClassLibraryVB
-
-'Class [MyClass]
-'
-' Overloads Shared Sub Main(ByVal args() As String)
-' Try
-' Dim myLib As New Class1
-' myLib.DoNothing()
-'
-' Console.WriteLine("Exiting the sample.")
-' Catch e As Exception
-' Console.WriteLine(e.Message)
-' End Try
-' End Sub
-'End Class
-Imports System.Security.Permissions
-
-'
-' Demand that the calling program be in the global assembly cache.
- _
-Public Class Class1
-'
- Public Sub DoNothing()
- Console.WriteLine("Exiting the library program.")
- End Sub
-End Class
-
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb
deleted file mode 100644
index 2d1b3207619..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.HostProtectionAttribute.1.1/VB/hostprotectionattribute.vb
+++ /dev/null
@@ -1,219 +0,0 @@
-'
-Imports System.IO
-Imports System.Threading
-Imports System.Security
-Imports System.Security.Policy
-Imports System.Security.Principal
-Imports System.Security.Permissions
-Imports System.Diagnostics
-Imports System.ComponentModel
-Imports System.Windows.Forms
-
-
-' If this application is run on a server that implements host protection, the
-' HostProtectionAttribute attribute is applied. If the application is run on
-' a server that is not host-protected, the attribute evaporates; it is not
-' detected and therefore not applied. Host protection can be configured with
-' members of the HostProtectionResource enumeration to customize the
-' protection offered.
-' The primary intent of this sample is to show situations in which the
-' HostProtectionAttribute attribute might be meaningfully used. The
-' environment required to demonstrate a particular behavior is too
-' complex to invoke within the scope of this sample.
-
-Class HostProtectionExample
- Public Shared Success As Integer = 100
-
- '
- ' Use the enumeration flags to indicate that this method exposes
- ' shared state and self-affecting process management.
- ' Either of the following attribute statements can be used to set the
- ' resource flags.
- _
- Private Shared Sub [Exit](ByVal Message As String, ByVal Code As Integer)
-
- ' Exit the sample when an exception is thrown.
- Console.WriteLine((ControlChars.Lf & "FAILED: " & Message & " " & _
- Code.ToString()))
- Environment.ExitCode = Code
- Environment.Exit(Code)
- End Sub
- '
-
- '
- ' Use the enumeration flags to indicate that this method exposes shared
- ' state, self-affecting process management, and self-affecting threading.
- _
- Private Shared Sub ExecuteBreak()
-
- ' This method allows the user to quit the sample.
- Console.WriteLine("Executing Debugger.Break.")
- Debugger.Break()
- Debugger.Log(1, "info", "test message")
- End Sub
- '
-
- '
- ' Use the enumeration flags to indicate that this method exposes shared
- ' state, self-affecting threading, and the security infrastructure.
- _
- Private Shared Function ApplyIdentity() As Integer
-
- ' ApplyIdentity sets the current identity.
- Dim roles(1) As String
- Try
- Dim mAD As AppDomain = AppDomain.CurrentDomain
- Dim mGenPr As _
- New GenericPrincipal(WindowsIdentity.GetCurrent(), roles)
- mAD.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal)
- mAD.SetThreadPrincipal(mGenPr)
- Return Success
- Catch e As Exception
- [Exit](e.ToString(), 5)
- End Try
- Return 0
- End Function 'ApplyIdentity
- '
-
- ' The following method is started on a separate thread.
- Public Shared Sub WatchFileEvents()
- Try
- Console.WriteLine("In the child thread.")
- Dim watcher As New FileSystemWatcher()
- watcher.Path = "C:\Temp"
-
- ' Watch for changes in LastAccess and LastWrite times, and
- ' name changes to files or directories.
- watcher.NotifyFilter = NotifyFilters.LastAccess Or _
- NotifyFilters.LastWrite Or NotifyFilters.FileName Or _
- NotifyFilters.DirectoryName
-
- ' Watch only text files.
- watcher.Filter = "*.txt"
-
- ' Add event handlers.
- AddHandler watcher.Changed, AddressOf OnChanged
- AddHandler watcher.Created, AddressOf OnChanged
- AddHandler watcher.Deleted, AddressOf OnChanged
-
- ' Begin watching.
- watcher.EnableRaisingEvents = True
-
- ' Wait for the user to quit the program.
- Console.WriteLine("Event handlers have been enabled.")
- While Console.ReadLine() <> "q"c
- End While
- Catch e As Exception
- Console.WriteLine(e.Message)
- End Try
- End Sub
-
- '
- ' Use the enumeration flags to indicate that this method exposes
- ' synchronization and external threading.
- _
- Private Shared Sub StartThread()
- Dim t As New Thread(New ThreadStart(AddressOf WatchFileEvents))
-
- ' Start the new thread. On a uniprocessor, the thread is not given
- ' any processor time until the main thread yields the processor.
- t.Start()
-
- ' Give the new thread a chance to execute.
- Thread.Sleep(1000)
- End Sub
- '
-
- ' Call methods that show the use of the HostProtectionResource enumeration.
- _
- Overloads Shared Function Main(ByVal args() As String) As Integer
- Try
- ' Show use of the HostProtectionResource.SharedState,
- ' HostProtectionResource.SelfAffectingThreading, and
- ' HostProtectionResource.Security enumeration values.
- ApplyIdentity()
- Directory.CreateDirectory("C:\Temp")
-
- ' Show use of the HostProtectionResource.Synchronization and
- ' HostProtectionResource.ExternalThreading enumeration values.
- StartThread()
- Console.WriteLine("In the main thread.")
- Console.WriteLine("Deleting and creating 'MyTestFile.txt'.")
- If File.Exists("C:\Temp\MyTestFile.txt") Then
- File.Delete("C:\Temp\MyTestFile.txt")
- End If
-
- Dim sr As StreamWriter = File.CreateText("C:\Temp\MyTestFile.txt")
- sr.WriteLine("This is my file.")
- sr.Close()
- Thread.Sleep(1000)
-
- ' Show use of the HostProtectionResource.SharedState,
- ' HostProtectionResource.SelfProcessMgmt,
- ' HostProtectionResource.SelfAffectingThreading, and
- ' HostProtectionResource.UI enumeration values.
- ExecuteBreak()
-
- ' Show the use of the
- ' HostProtectionResource.ExternalProcessManagement
- ' enumeration value.
- Dim myControl As New MyControl()
- Console.WriteLine("Enter 'q' to quit the sample.")
- Return 100
- Catch e As Exception
- [Exit](e.ToString(), 0)
- Return 0
- End Try
- End Function 'Main
-
- ' Define the event handlers.
- Private Shared Sub OnChanged(ByVal [source] As Object, _
- ByVal e As FileSystemEventArgs)
-
- ' Specify whether a file is changed, created, or deleted.
- Console.WriteLine("In the OnChanged event handler.")
- Console.WriteLine(("File: " & e.FullPath & " " & _
- e.ChangeType.ToString()))
- End Sub
-End Class
-
-'
-' The following class is an example of code that exposes
-' external process management.
-' Add the LicenseProviderAttribute to the control.
- _
-Public Class MyControl
- Inherits System.Windows.Forms.Control
-
- ' Create a new, null license.
- Private license As License = Nothing
-
- _
- Public Sub New()
-
- ' Determine if a valid license can be granted.
- Dim isValid As Boolean = LicenseManager.IsValid(GetType(MyControl))
- Console.WriteLine(("The result of the IsValid method call is " & _
- isValid.ToString()))
- End Sub
-
- Protected Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (license Is Nothing) Then
- license.Dispose()
- license = Nothing
- End If
- End If
- End Sub
-End Class
-'
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb
deleted file mode 100644
index 20fc1171561..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.KeyContainerPermission/VB/Form1.vb
+++ /dev/null
@@ -1,270 +0,0 @@
-'
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Security.Cryptography
-
-
-
-Public Class KeyContainerPermissionDemo
- Private Shared cspParams As New CspParameters()
- Private Shared rsa As New RSACryptoServiceProvider()
- Private Shared providerName As String
- Private Shared providerType As Integer
- Private Shared myKeyContainerName As String
- ' Create three KeyContainerPermissionAccessEntry objects, each with a different constructor.
- '
- Private Shared keyContainerPermAccEntry1 As _
- New KeyContainerPermissionAccessEntry("MyKeyContainer", KeyContainerPermissionFlags.Create)
- '
- '
- Private Shared keyContainerPermAccEntry2 As _
- New KeyContainerPermissionAccessEntry(cspParams, KeyContainerPermissionFlags.Open)
- '
- '
- Private Shared keyContainerPermAccEntry3 As _
- New KeyContainerPermissionAccessEntry("Machine", providerName, providerType, _
- myKeyContainerName, 1, KeyContainerPermissionFlags.Open)
-
- '
-
- Public Shared Function Main() As Integer
- Try
- ' Create a key container for use in the sample.
- GenKey_SaveInContainer("MyKeyContainer")
- ' Initialize property values for creating a KeyContainerPermissionAccessEntry object.
- myKeyContainerName = rsa.CspKeyContainerInfo.KeyContainerName
- providerName = rsa.CspKeyContainerInfo.ProviderName
- providerType = rsa.CspKeyContainerInfo.ProviderType
- cspParams.KeyContainerName = myKeyContainerName
- cspParams.ProviderName = providerName
- cspParams.ProviderType = providerType
-
- ' Display the KeyContainerPermissionAccessEntry properties using
- ' the third KeyContainerPermissionAccessEntry object.
- DisplayAccessEntryMembers()
- '
- ' Add access entry objects to a key container permission.
- Dim keyContainerPerm1 As New KeyContainerPermission(PermissionState.Unrestricted)
- Console.WriteLine("Is the permission unrestricted? " + _
- keyContainerPerm1.IsUnrestricted().ToString())
- keyContainerPerm1.AccessEntries.Add(keyContainerPermAccEntry1)
- keyContainerPerm1.AccessEntries.Add(keyContainerPermAccEntry2)
- '
- ' Display the permission.
- System.Console.WriteLine(keyContainerPerm1.ToXml().ToString())
-
- '
- ' Create an array of KeyContainerPermissionAccessEntry objects
- Dim keyContainerPermAccEntryArray As KeyContainerPermissionAccessEntry() = _
- {keyContainerPermAccEntry1, keyContainerPermAccEntry2}
-
- ' Create a new KeyContainerPermission using the array.
- Dim keyContainerPerm2 As _
- New KeyContainerPermission(KeyContainerPermissionFlags.AllFlags, keyContainerPermAccEntryArray)
- '
- DisplayPermissionMembers(keyContainerPerm2, keyContainerPermAccEntryArray)
-
- ' Demonstrate the effect of a deny for opening a key container.
- DenyOpen()
- ' Demonstrate the deletion of a key container.
- DeleteContainer()
-
- Console.WriteLine("Press the Enter key to exit.")
- Console.Read()
- Return 0
- ' Close the current try block that did not expect an exception.
- Catch e As Exception
- Console.WriteLine("Unexpected exception thrown: " + e.Message)
- Return 0
- End Try
-
- End Function 'Main
-
-
- Private Shared Sub DisplayAccessEntryMembers()
- '
- Console.WriteLine(vbLf + "KeycontainerName is " + _
- keyContainerPermAccEntry3.KeyContainerName)
- '
- '
- Console.WriteLine("KeySpec is " + IIf(1 = keyContainerPermAccEntry3.KeySpec, _
- "AT_KEYEXCHANGE ", "AT_SIGNATURE"))
- '
- '
- Console.WriteLine("KeyStore is " + keyContainerPermAccEntry3.KeyStore)
- '
- '
- Console.WriteLine("ProviderName is " + keyContainerPermAccEntry3.ProviderName)
- '
- '
- Console.WriteLine("ProviderType is " + IIf(1 = keyContainerPermAccEntry3.ProviderType, _
- "PROV_RSA_FULL", keyContainerPermAccEntry3.ProviderType.ToString()))
- '
- '
- Console.WriteLine("Hashcode = " + keyContainerPermAccEntry3.GetHashCode().ToString())
- '
- '
- Console.WriteLine("Are the KeyContainerPermissionAccessEntry objects equal? " + _
- keyContainerPermAccEntry3.Equals(keyContainerPermAccEntry2).ToString())
-
- End Sub
- '
-
- Private Shared Sub DisplayPermissionMembers(ByVal keyContainerPermParam As _
- KeyContainerPermission, ByVal keyContainerPermAccEntryArrayParam() _
- As KeyContainerPermissionAccessEntry)
- Dim keyContainerPerm2 As KeyContainerPermission = keyContainerPermParam
- Dim keyContainerPermAccEntryArray As KeyContainerPermissionAccessEntry() = _
- keyContainerPermAccEntryArrayParam
- ' Display the KeyContainerPermission properties.
- '
- Console.WriteLine(vbLf + "Flags value is " + keyContainerPerm2.Flags.ToString())
- '
- '
- Dim keyContainerPerm3 As KeyContainerPermission = _
- CType(keyContainerPerm2.Copy(), KeyContainerPermission)
- Console.WriteLine("Is the copy equal to the original? " + _
- keyContainerPerm3.Equals(keyContainerPerm2).ToString())
- '
- '
- ' Perform an XML roundtrip.
- keyContainerPerm3.FromXml(keyContainerPerm2.ToXml())
- Console.WriteLine("Was the XML roundtrip successful? " + _
- keyContainerPerm3.Equals(keyContainerPerm2).ToString())
- '
- Dim keyContainerPerm4 As New KeyContainerPermission(KeyContainerPermissionFlags.Open, _
- keyContainerPermAccEntryArray)
- '
- Dim keyContainerPerm5 As KeyContainerPermission = _
- CType(keyContainerPerm2.Intersect(keyContainerPerm4), KeyContainerPermission)
- Console.WriteLine("Flags value after the intersection is " + _
- keyContainerPerm5.Flags.ToString())
- '
- '
- keyContainerPerm5 = CType(keyContainerPerm2.Union(keyContainerPerm4), _
- KeyContainerPermission)
- '
- '
- Console.WriteLine("Flags value after the union is " + _
- keyContainerPerm5.Flags.ToString())
- '
- '
- Console.WriteLine("Is one permission a subset of the other? " + _
- keyContainerPerm4.IsSubsetOf(keyContainerPerm2).ToString())
-
- End Sub
- '
-
- Private Shared Sub GenKey_SaveInContainer(ByVal containerName As String)
- ' Create the CspParameters object and set the key container
- ' name used to store the RSA key pair.
- cspParams = New CspParameters()
-
- cspParams.KeyContainerName = containerName
-
- ' Create a new instance of RSACryptoServiceProvider that accesses
- ' the key container identified by the containerName parameter.
- rsa = New RSACryptoServiceProvider(cspParams)
-
- ' Display the key information to the console.
- Console.WriteLine(vbLf + "Key added to container: " + vbLf + " {0}", _
- rsa.ToXmlString(True))
-
- End Sub
-
- Private Shared Sub GetKeyFromContainer(ByVal containerName As String)
- Try
- cspParams = New CspParameters()
- cspParams.KeyContainerName = containerName
-
- ' Create a new instance of RSACryptoServiceProvider that accesses
- ' the key container identified by the containerName parameter.
- ' If the key container does not exist, a new one is created.
- rsa = New RSACryptoServiceProvider(cspParams)
-
- ' Use the rsa object to access the key.
- ' Display the key information to the console.
- Console.WriteLine(vbLf + "Key retrieved from container : " + _
- vbLf + " {0}", rsa.ToXmlString(True))
- Console.WriteLine("KeycontainerName is " + rsa.CspKeyContainerInfo.KeyContainerName)
- Console.WriteLine("ProviderName is " + rsa.CspKeyContainerInfo.ProviderName)
- Console.WriteLine("ProviderType is " + IIf(1 = _
- rsa.CspKeyContainerInfo.ProviderType, "PROV_RSA_FULL", _
- rsa.CspKeyContainerInfo.ProviderType.ToString()))
- Catch e As Exception
- Console.WriteLine("Exception thrown: " + e.Message)
- End Try
-
- End Sub
-
- Private Shared Sub DeleteKeyContainer(ByVal containerName As String)
- ' Create the CspParameters object and set the key container
- ' name used to store the RSA key pair.
- cspParams = New CspParameters()
- cspParams.KeyContainerName = containerName
-
- ' Create a new instance of RSACryptoServiceProvider that accesses
- ' the key container.
- rsa = New RSACryptoServiceProvider(cspParams)
-
- ' Do not persist the key entry, effectively deleting the key.
- rsa.PersistKeyInCsp = False
-
- ' Call Clear to release the key container resources.
- rsa.Clear()
- Console.WriteLine(vbLf + "Key container released.")
-
- End Sub
-
- Private Shared Sub DenyOpen()
- Try
- '
- ' Create a KeyContainerPermission with the right to open the key container.
- Dim keyContainerPerm As New KeyContainerPermission(KeyContainerPermissionFlags.Open)
-
- '
- ' Demonstrate the results of a deny for an open action.
- keyContainerPerm.Deny()
-
- ' The next line causes an exception to be thrown when the infrastructure code attempts
- ' to open the key container.
- Dim info As New CspKeyContainerInfo(cspParams)
- Catch e As Exception
- Console.WriteLine("Expected exception thrown: " + e.Message)
- End Try
-
- ' Revert the deny.
- CodeAccessPermission.RevertDeny()
-
- End Sub
-
- Private Shared Sub DeleteContainer()
- Try
- ' Create a KeyContainerPermission with the right to create a key container.
- Dim keyContainerPerm As New KeyContainerPermission(KeyContainerPermissionFlags.Create)
-
- ' Deny the ability to create a key container.
- ' This deny is used to show the key container has been successfully deleted.
- keyContainerPerm.Deny()
-
- ' Retrieve the key from the container.
- ' This code executes successfully because the key container already exists.
- ' The deny for permission to create a key container does not affect this method call.
- GetKeyFromContainer("MyKeyContainer")
-
- ' Delete the key and the container.
- DeleteKeyContainer("MyKeyContainer")
-
- ' Attempt to obtain the key from the deleted key container.
- ' This time the method call results in an exception because of
- ' an attempt to create a new key container.
- Console.WriteLine(vbLf + _
- "Attempt to create a new key container with create permission denied.")
- GetKeyFromContainer("MyKeyContainer")
- Catch e As CryptographicException
- Console.WriteLine("Expected exception thrown: " + e.Message)
- End Try
-
- End Sub
-End Class
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb
deleted file mode 100644
index 352c67051d7..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.NameIdPermission/VB/nameidpermission.vb
+++ /dev/null
@@ -1,217 +0,0 @@
-#Const debug = True
-'
-' This custom permission is intended only for the purposes of illustration.
-' The following code shows how to create a custom permission that inherits
-' from CodeAccessPermission. The code implements all required overrides.
-' A wildcard character ('*') is implemented for the Name property.
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.IO
-Imports System.Security.Policy
-Imports System.Collections
-
-
-
-
-Namespace MyPermission
-
- _
- Public NotInheritable Class NameIdPermission
- Inherits CodeAccessPermission
- Implements IUnrestrictedPermission
- Private m_Name As String
- Private m_Unrestricted As Boolean
-
-
- Public Sub New(ByVal name As String)
- m_name = name
- End Sub
-
-
- Public Sub New(ByVal state As PermissionState)
- If state = PermissionState.None Then
- m_name = ""
- ElseIf state = PermissionState.Unrestricted Then
- Throw New ArgumentException("Unrestricted state is not allowed for identity permissions.")
- Else
- Throw New ArgumentException("Invalid permission state.")
- End If
- End Sub
-
- Public Property Name() As String
- Get
- Return m_name
- End Get
- Set(ByVal Value As String)
- m_name = Value
- End Set
- End Property
-
- '
- Public Overrides Function Copy() As IPermission
- Dim name As String
- name = m_name
- Return New NameIdPermission(name)
- End Function 'Copy
-
- '
- '
- Public Function IsUnrestricted() As Boolean Implements IUnrestrictedPermission.IsUnrestricted
- ' Always false, unrestricted state is not allowed.
- Return m_Unrestricted
- End Function
- '
- Private Function VerifyType(ByVal target As IPermission) As Boolean
- Return TypeOf target Is NameIdPermission
- End Function 'VerifyType
-
- '
- Public Overrides Function IsSubsetOf(ByVal target As IPermission) As Boolean
-
-#If (Debug) Then
-
- Console.WriteLine("************* Entering IsSubsetOf *********************")
-#End If
- If target Is Nothing Then
- Console.WriteLine("IsSubsetOf: target == null")
- Return False
- End If
-#If (Debug) Then
- Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
- Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
-#End If
- Try
- Dim operand As NameIdPermission = CType(target, NameIdPermission)
-
- ' The following check for unrestricted permission is only included as an example for
- ' permissions that allow the unrestricted state. It is of no value for this permission.
- If True = operand.m_Unrestricted Then
- Return True
- ElseIf True = Me.m_Unrestricted Then
- Return False
- End If
-
- If Not (Me.m_name Is Nothing) Then
- If operand.m_name Is Nothing Then
- Return False
- End If
- If Me.m_name = "" Then
- Return True
- End If
- End If
- If Me.m_name.Equals(operand.m_name) Then
- Return True
- Else
- ' Check for wild card character '*'.
- Dim i As Integer = operand.m_name.LastIndexOf("*")
-
- If i > 0 Then
- Dim prefix As String = operand.m_name.Substring(0, i)
-
- If Me.m_name.StartsWith(prefix) Then
- Return True
- End If
- End If
- End If
-
- Return False
- Catch
- Throw New ArgumentException(String.Format("Argument_WrongType", Me.GetType().FullName))
- End Try
- End Function
-
- '
- '
- Public Overrides Function Intersect(ByVal target As IPermission) As IPermission
- Console.WriteLine("************* Entering Intersect *********************")
- If target Is Nothing Then
- Return Nothing
- End If
-#If (Debug) Then
-
- Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
- Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
-#End If
- If Not VerifyType(target) Then
- Throw New ArgumentException(String.Format("Argument is wrong type.", Me.GetType().FullName))
- End If
-
- Dim operand As NameIdPermission = CType(target, NameIdPermission)
-
- If operand.IsSubsetOf(Me) Then
- Return operand.Copy()
- ElseIf Me.IsSubsetOf(operand) Then
- Return Me.Copy()
- Else
- Return Nothing
- End If
- End Function 'Intersect
- '
-
- '
- Public Overrides Function Union(ByVal target As IPermission) As IPermission
-#If (Debug) Then
-
- Console.WriteLine("************* Entering Union *********************")
-#End If
- If target Is Nothing Then
- Return Me
- End If
-#If (Debug) Then
- Console.WriteLine(("This is = " + CType(Me, NameIdPermission).Name))
- Console.WriteLine(("Target is " + CType(target, NameIdPermission).m_name))
-#End If
- If Not VerifyType(target) Then
- Throw New ArgumentException(String.Format("Argument_WrongType", Me.GetType().FullName))
- End If
-
- Dim operand As NameIdPermission = CType(target, NameIdPermission)
-
- If operand.IsSubsetOf(Me) Then
- Return Me.Copy()
- ElseIf Me.IsSubsetOf(operand) Then
- Return operand.Copy()
- Else
- Return Nothing
- End If
- End Function 'Union
- '
-
- '
- Public Overrides Sub FromXml(ByVal e As SecurityElement)
- ' The following code for unrestricted permission is only included as an example for
- ' permissions that allow the unrestricted state. It is of no value for this permission.
- Dim elUnrestricted As String = e.Attribute("Unrestricted")
- If Nothing <> elUnrestricted Then
- m_Unrestricted = Boolean.Parse(elUnrestricted)
- Return
- End If
-
- Dim elName As String = e.Attribute("Name")
- m_name = IIf(elName Is Nothing, Nothing, elName)
- End Sub
-
- '
- '
- Public Overrides Function ToXml() As SecurityElement
- ' Use the SecurityElement class to encode the permission to XML.
- Dim esd As New SecurityElement("IPermission")
-
- Dim name As String = GetType(NameIdPermission).AssemblyQualifiedName
- esd.AddAttribute("class", name)
- esd.AddAttribute("version", "1.0")
-
- ' The following code for unrestricted permission is only included as an example for
- ' permissions that allow the unrestricted state. It is of no value for this permission.
- If m_Unrestricted Then
- esd.AddAttribute("Unrestricted", True.ToString())
- End If
- If Not (m_Name Is Nothing) Then
- esd.AddAttribute("Name", m_Name)
- End If
- Return esd
- End Function 'ToXml
- End Class
- '
-End Namespace
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb
deleted file mode 100644
index 38179922142..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PermissionSetAttribute/VB/Form1.vb
+++ /dev/null
@@ -1,319 +0,0 @@
-'
-' The #Const BuildFile = True statement must be active the first time this
-' sample is run. This causes the sample to create a file named
-' 'LocalIntranet.xml' in the c:\temp folder. After creating the
-' LocalInternet.xml file, comment out the #Const BUILDFILE = True statement,
-' uncomment the #Const BUILDFILE = False statement, and rerun the sample to
-' demonstrate the use of the permission set attribute.
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Security.Policy
-Imports System.Collections
-Imports System.IO
-
-#Const BUILDFILE = True
-'#Const BUILDFILE = False
-
-Public Class Form1
- Inherits System.Windows.Forms.Form
-
- ' Event handler for Run button.
- _
- Private Sub Button1_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button1.Click
-
- tbxOutput.Cursor = Cursors.WaitCursor
- tbxOutput.Text = ""
-
- Dim xmlFilePath As String
- xmlFilePath = "c:\temp\LocalIntranet.xml"
-
- ' Run this sample with the BuildFile symbol defined to create the
- ' required file, then comment out the /define statement to demonstrate
- ' the use of the attribute.
-#If (BUILDFILE) Then
- Dim sw As New StreamWriter(xmlFilePath)
- Try
- sw.WriteLine(GetNamedPermissionSet("LocalIntranet"))
- WriteLine("File created at " + xmlFilePath)
- WriteLine("Uncomment the BuildFile=false line and " + _
- "run the sample again.")
- Finally
- sw.Close()
- End Try
-#End If
-
-#If (Not BUILDFILE) Then
- ReadFile1()
- ReadFile2()
- ReadFile3()
-#End If
- ' Align interface and conclude application.
- WriteLine(vbCrLf + "This sample completed successfully;" + _
- " press Exit to continue.")
-
- ' Reset the cursor.
- tbxOutput.Cursor = Cursors.Default
- End Sub
-
-#If (Not BUILDFILE) Then
- ' Read the LocalIntranet.xml file.
- Private Sub ReadFile1()
- Try
- WriteLine("Attempting to read a file using the FullTrust " + _
- "permission set.")
- Dim sr As New StreamReader("c:\temp\LocalIntranet.xml")
- Try
- Dim permissionSet As String = sr.ReadToEnd()
- Finally
- sr.Close()
- End Try
- WriteLine("The file was successfully read.")
- Catch e As Exception
- WriteLine(e.Message)
- End Try
- End Sub
-
- '
- _
- Private Sub ReadFile2()
- '
- ' Read the file with the specified security action on the file path.
- Try
- WriteLine("Attempting to read a file using the LocalIntranet " + _
- "permission set.")
- Dim sr As New StreamReader("c:\temp\LocalIntranet.xml")
- Try
- Dim permissionSet As String = sr.ReadToEnd()
- Finally
- sr.Close()
- End Try
- WriteLine("The file was successfully read.")
- Catch e As Exception
- WriteLine(e.Message)
- End Try
- End Sub
-
- '
- _
- Private Sub ReadFile3()
- '
- ' Read the file with the specified security action on the
- ' permission set.
- Try
- WriteLine("Second attempt to read a file using the " + _
- "LocalIntranet permission set.")
- Dim sr As New StreamReader("c:\temp\LocalIntranet.xml")
- Try
- Dim permissionSet As String = sr.ReadToEnd()
- Finally
- sr.Close()
- End Try
- WriteLine("The file was successfully read.")
- Catch e As Exception
- WriteLine(e.Message)
- End Try
- End Sub
-#End If
-
- ' Locate the named permission set at the Machine level and return it as
- ' a string value.
- Private Shared Function GetNamedPermissionSet( _
- ByVal name As String) As String
-
- Dim policyEnumerator As IEnumerator
- policyEnumerator = SecurityManager.PolicyHierarchy()
-
- ' Move through the policy levels to the Machine Level.
- While policyEnumerator.MoveNext()
- Dim currentLevel As PolicyLevel
- currentLevel = CType(policyEnumerator.Current, PolicyLevel)
- If currentLevel.Label = "Machine" Then
- ' Iterate through the permission sets at the Machine level.
- Dim namedPermissions As IList
- namedPermissions = currentLevel.NamedPermissionSets
-
- Dim namedPermission As IEnumerator
- namedPermission = namedPermissions.GetEnumerator()
-
- Dim currentPermission As NamedPermissionSet
- ' Locate the named permission set.
- While namedPermission.MoveNext()
- currentPermission = CType( _
- namedPermission.Current, _
- NamedPermissionSet)
-
- If currentPermission.Name.Equals(name) Then
- Return currentPermission.ToString()
- End If
- End While
- End If
- End While
- Return Nothing
- End Function
-
- ' Write specified message and carriage return to the output textbox.
- Private Sub WriteLine(ByVal message As String)
- tbxOutput.AppendText(message + vbCrLf)
-
- End Sub
-
- ' Event handler for Exit button.
- Private Sub Button2_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button2.Click
-
- Application.Exit()
- End Sub
-#Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.IContainer
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- Friend WithEvents Panel2 As System.Windows.Forms.Panel
- Friend WithEvents Panel1 As System.Windows.Forms.Panel
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents Button2 As System.Windows.Forms.Button
- Friend WithEvents tbxOutput As System.Windows.Forms.RichTextBox
- _
- Private Sub InitializeComponent()
- Me.Panel2 = New System.Windows.Forms.Panel
- Me.Button1 = New System.Windows.Forms.Button
- Me.Button2 = New System.Windows.Forms.Button
- Me.Panel1 = New System.Windows.Forms.Panel
- Me.tbxOutput = New System.Windows.Forms.RichTextBox
- Me.Panel2.SuspendLayout()
- Me.Panel1.SuspendLayout()
- Me.SuspendLayout()
- '
- 'Panel2
- '
- Me.Panel2.Controls.Add(Me.Button1)
- Me.Panel2.Controls.Add(Me.Button2)
- Me.Panel2.Dock = System.Windows.Forms.DockStyle.Bottom
- Me.Panel2.DockPadding.All = 20
- Me.Panel2.Location = New System.Drawing.Point(0, 320)
- Me.Panel2.Name = "Panel2"
- Me.Panel2.Size = New System.Drawing.Size(616, 64)
- Me.Panel2.TabIndex = 1
- '
- 'Button1
- '
- Me.Button1.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button1.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button1.Location = New System.Drawing.Point(446, 20)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(75, 24)
- Me.Button1.TabIndex = 2
- Me.Button1.Text = "&Run"
- '
- 'Button2
- '
- Me.Button2.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button2.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button2.Location = New System.Drawing.Point(521, 20)
- Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(75, 24)
- Me.Button2.TabIndex = 3
- Me.Button2.Text = "E&xit"
- '
- 'Panel1
- '
- Me.Panel1.Controls.Add(Me.tbxOutput)
- Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
- Me.Panel1.DockPadding.All = 20
- Me.Panel1.Location = New System.Drawing.Point(0, 0)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(616, 320)
- Me.Panel1.TabIndex = 2
- '
- 'tbxOutput
- '
- Me.tbxOutput.AccessibleDescription = _
- "Displays output from application."
- Me.tbxOutput.AccessibleName = "Output textbox."
- Me.tbxOutput.Dock = System.Windows.Forms.DockStyle.Fill
- Me.tbxOutput.Location = New System.Drawing.Point(20, 20)
- Me.tbxOutput.Name = "tbxOutput"
- Me.tbxOutput.Size = New System.Drawing.Size(576, 280)
- Me.tbxOutput.TabIndex = 1
- Me.tbxOutput.Text = "Click the Run button to run the application."
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
- Me.ClientSize = New System.Drawing.Size(616, 384)
- Me.Controls.Add(Me.Panel1)
- Me.Controls.Add(Me.Panel2)
- Me.Name = "Form1"
- Me.Text = "PermisstionSetAttribute"
- Me.Panel2.ResumeLayout(False)
- Me.Panel1.ResumeLayout(False)
- Me.ResumeLayout(False)
-
- End Sub
-
-#End Region
-End Class
-'
-' This sample produces the following output:
-'
-' File created at c:\temp\LocalIntranet.xml
-' Uncomment the BuildFile=false line and run the sample again.
-'
-' This sample completed successfully; press Exit to continue.
-'
-'
-' The second time the sample is ran (without DEBUG flag):
-'
-' Attempting to read a file using the FullTrust permission set.
-' The file was successfully read.
-' Attempting to read a file using the LocalIntranet permission set.
-' Request for the permission of type
-' System.Security.Permissions.FileIOPermission, mscorlib, Version=1.0.5000.0,
-' Culture=neutral, PublicKeyToken=b77a5c561934e089 failed.
-'
-' Second attempt to read a file using the LocalIntranet permission set.
-' Request for the permission of type System.Security.Permissions.FileIOPermission,
-' mscorlib, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-' failed.
-' This sample completed successfully; press Exit to continue.
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/VB/publisheridentitypermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/VB/publisheridentitypermission.vb
deleted file mode 100644
index e26f654d389..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.PublisherIdentityPermission/VB/publisheridentitypermission.vb
+++ /dev/null
@@ -1,116 +0,0 @@
-'
-' To execute this sample you will need two certification files, MyCert1.cer and MyCert2.cer.
-' The certification files can be created using the Certification Creation Tool, MakeCert.exe.
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Security.Cryptography.X509Certificates
-Imports System.IO
-
-
-
-Public Class PublisherIdentityPermissionDemo
- Private Shared publisherCertificate(1) As X509Certificate
- Private Shared publisherPerm1 As PublisherIdentityPermission
- Private Shared publisherPerm2 As PublisherIdentityPermission
-
- ' Demonstrate all methods.
- Public Shared Sub Main(ByVal args() As String)
- ' Initialize the PublisherIdentityPermissions for use in the sample
- '
- Dim fs1 As New FileStream("..\..\..\MyCert1.cer", FileMode.Open)
- Dim certSBytes1(Fix(fs1.Length)) As [Byte]
- fs1.Read(certSBytes1, 0, Fix(fs1.Length))
- publisherCertificate(0) = New X509Certificate(certSBytes1)
- fs1.Close()
- Dim fs2 As New FileStream("..\..\..\MyCert2.cer", FileMode.Open)
- Dim certSBytes2(Fix(fs2.Length)) As [Byte]
- fs2.Read(certSBytes2, 0, Fix(fs2.Length))
- publisherCertificate(1) = New X509Certificate(certSBytes2)
- fs2.Close()
-
- publisherPerm1 = New PublisherIdentityPermission(publisherCertificate(0))
- publisherPerm2 = New PublisherIdentityPermission(publisherCertificate(1))
- '
- IsSubsetOfDemo()
- CopyDemo()
- UnionDemo()
- IntersectDemo()
- ToFromXmlDemo()
-
- End Sub
-
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- '
- Private Shared Sub IsSubsetOfDemo()
-
- If publisherPerm2.IsSubsetOf(publisherPerm1) Then
- Console.WriteLine(publisherPerm2.Certificate.Subject.ToString() + _
- " is a subset of " + publisherPerm1.Certificate.Subject.ToString())
- Else
- Console.WriteLine(publisherPerm2.Certificate.Subject.ToString() + _
- " is not a subset of " + publisherPerm1.Certificate.Subject.ToString())
- End If
-
- End Sub
-
- '
- ' Union creates a new permission that is the union of the current permission and the specified permission.
- '
- Private Shared Sub UnionDemo()
- Dim publisherPerm3 As PublisherIdentityPermission = CType(publisherPerm1.Union(publisherPerm2), PublisherIdentityPermission)
- If publisherPerm3 Is Nothing Then
- Console.WriteLine("The union of " + publisherPerm1.ToString() + " and " _
- + publisherPerm2.Certificate.Subject.ToString() + " is null.")
- Else
- Console.WriteLine("The union of " + publisherPerm1.Certificate.Subject.ToString() + _
- " and " + publisherPerm2.Certificate.Subject.ToString() + " = " + _
- CType(publisherPerm3, PublisherIdentityPermission).Certificate.Subject.ToString())
- End If
-
- End Sub
-
-
- '
- ' Intersect creates and returns a new permission that is the intersection of the current
- ' permission and the permission specified.
- '
- Private Shared Sub IntersectDemo()
- Dim publisherPerm3 As PublisherIdentityPermission = CType(publisherPerm1.Union(publisherPerm2), PublisherIdentityPermission)
- If Not (publisherPerm3 Is Nothing) Then
- Console.WriteLine("The intersection of " + publisherPerm1.Certificate.Subject.ToString() + " = " + _
- CType(publisherPerm3, PublisherIdentityPermission).Certificate.Subject.ToString())
- Else
- Console.WriteLine("The intersection of " + publisherPerm1.Certificate.Subject.ToString() + _
- " and " + publisherPerm2.Certificate.Subject.ToString() + " is null.")
- End If
-
- End Sub
-
-
- '
- 'Copy creates and returns an identical copy of the current permission.
- '
- Private Shared Sub CopyDemo()
- '
- ' Create an empty PublisherIdentityPermission to serve as the target of the copy.
- publisherPerm2 = New PublisherIdentityPermission(PermissionState.None)
- publisherPerm2 = CType(publisherPerm1.Copy(), PublisherIdentityPermission)
- Console.WriteLine("Result of copy = " + publisherPerm2.ToString())
-
- End Sub
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state;
- ' FromXml reconstructs a permission with the specified state from the XML encoding.
- '
- Private Shared Sub ToFromXmlDemo()
- publisherPerm2 = New PublisherIdentityPermission(PermissionState.None)
- publisherPerm2.FromXml(publisherPerm1.ToXml())
- Console.WriteLine("Result of ToFromXml = " + publisherPerm2.ToString())
-
- End Sub
-End Class
-'
-
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb
deleted file mode 100644
index d7a582a7d36..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ReflectionPermission/VB/reflectionpermission.vb
+++ /dev/null
@@ -1,122 +0,0 @@
-' This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml and FromXml methods
-' of the ReflectionPermission class.
-'
-Imports System.Security
-Imports System.Security.Permissions
-
-
-
-Public Class ReflectionPermissionDemo
-
- ' Demonstrate all methods.
- Public Shared Sub Main(ByVal args() As String)
- IsSubsetOfDemo()
- CopyDemo()
- UnionDemo()
- IntersectDemo()
- ToFromXmlDemo()
- Console.WriteLine("Press the Enter key to exit.")
- Console.ReadLine()
-
- End Sub
-
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- '
- Private Shared Sub IsSubsetOfDemo()
-
- Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
- '
- Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)
- '
- If restrictedMemberAccessPerm.IsSubsetOf(memberAccessPerm) Then
- Console.WriteLine(restrictedMemberAccessPerm.Flags + " is a subset of " + memberAccessPerm.Flags)
- Else
- Console.WriteLine(restrictedMemberAccessPerm.Flags.ToString() + _
- " is not a subset of " + memberAccessPerm.Flags.ToString())
- End If
-
- End Sub
-
- '
- ' Union creates a new permission that is the union of the current permission and the specified permission.
- '
- Private Shared Sub UnionDemo()
- Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
- Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)
- Dim reflectionPerm3 As ReflectionPermission = _
- CType(memberAccessPerm.Union(restrictedMemberAccessPerm), ReflectionPermission)
- If reflectionPerm3 Is Nothing Then
- Console.WriteLine("The union of " + memberAccessPerm.Flags.ToString() + " and " + _
- restrictedMemberAccessPerm.Flags.ToString() + " is null.")
- Else
- Console.WriteLine("The union of " + memberAccessPerm.Flags.ToString() + _
- " and " + restrictedMemberAccessPerm.Flags.ToString() + " = " + _
- CType(reflectionPerm3, ReflectionPermission).Flags.ToString())
- End If
-
- End Sub
-
-
- '
- ' Intersect creates and returns a new permission that is the intersection of the current
- ' permission and the permission specified.
- '
- Private Shared Sub IntersectDemo()
- Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
- Dim restrictedMemberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.RestrictedMemberAccess)
- Dim reflectionPerm3 As ReflectionPermission = CType(memberAccessPerm.Intersect(restrictedMemberAccessPerm), ReflectionPermission)
- If Not (reflectionPerm3 Is Nothing) Then
- Console.WriteLine("The intersection of " + memberAccessPerm.Flags.ToString() + _
- " and " + restrictedMemberAccessPerm.Flags.ToString() + " = " + _
- CType(reflectionPerm3, ReflectionPermission).Flags.ToString())
- Else
- Console.WriteLine("The intersection of " + memberAccessPerm.Flags.ToString + " and " + _
- restrictedMemberAccessPerm.Flags.ToString() + " is null.")
- End If
-
- End Sub
-
-
- '
- 'Copy creates and returns an identical copy of the current permission.
- '
- Private Shared Sub CopyDemo()
- Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
- Dim restrictedMemberAccessPerm As ReflectionPermission = CType(memberAccessPerm.Copy(), ReflectionPermission)
- Console.WriteLine("Result of copy = " + restrictedMemberAccessPerm.ToString())
-
- End Sub
-
- '
- ' ToXml creates an XML encoding of the permission and its current state;
- ' FromXml reconstructs a permission with the specified state from the XML encoding.
- '
- Private Shared Sub ToFromXmlDemo()
- Dim memberAccessPerm As New ReflectionPermission(ReflectionPermissionFlag.MemberAccess)
- '
- Dim restrictedMemberAccessPerm As New ReflectionPermission(PermissionState.None)
- '
- restrictedMemberAccessPerm.FromXml(memberAccessPerm.ToXml())
- Console.WriteLine("Result of ToFromXml = " + restrictedMemberAccessPerm.ToString())
-
- End Sub
-End Class
-'
-
-' This code example creates the following output:
-'RestrictedMemberAccess is not a subset of MemberAccess
-'Result of copy =
-'The union of MemberAccess and RestrictedMemberAccess = MemberAccess, RestrictedM
-'emberAccess
-'The intersection of MemberAccess and RestrictedMemberAccess is null.
-'Result of ToFromXml =
-'Press the Enter key to exit.
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb
deleted file mode 100644
index 271f9dd2587..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.RegistryPermission/VB/registrypermission.vb
+++ /dev/null
@@ -1,159 +0,0 @@
-'
-' This sample demonstrates the IsSubsetOf, Union, Intersect, Copy, ToXml, FromXml
-' GetPathList, AddPathList, and SetPathList methods
-' of the RegistryPermission class.
-
-Imports System.Security
-Imports System.Security.Permissions
-Imports System.Collections
-
-Public Class RegistryPermissionDemo
- Private Shared readPerm1 As New RegistryPermission(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
- Private Shared readPerm2 As New RegistryPermission(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION")
- Private Shared readPerm3 As New RegistryPermission(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0")
- Private Shared createPerm1 As New RegistryPermission(RegistryPermissionAccess.Create, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
- Private Shared readPerm4 As IPermission
-
- Public Shared Sub Main(ByVal args() As String)
-
- IsSubsetOfDemo()
- UnionDemo()
- IntersectDemo()
- CopyDemo()
- ToFromXmlDemo()
- SetGetPathListDemo()
-
- End Sub
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Shared Function IsSubsetOfDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- If readPerm1.IsSubsetOf(readPerm2) Then
-
- Console.WriteLine(readPerm1.GetPathList(RegistryPermissionAccess.Read) + vbLf + " is a subset of " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + vbLf)
- Else
- Console.WriteLine(readPerm1.GetPathList(RegistryPermissionAccess.Read) + vbLf + " is not a subset of " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + vbLf)
- End If
- If createPerm1.IsSubsetOf(readPerm1) Then
-
- Console.WriteLine("RegistryPermissionAccess.Create" + vbLf + " is a subset of " + "RegistryPermissionAccess.Read" + vbLf)
- Else
- Console.WriteLine("RegistryPermissionAccess.Create" + vbLf + " is not a subset of " + "RegistryPermissionAccess.Read" + vbLf)
- End If
-
- Return returnValue
-
- End Function 'IsSubsetOfDemo
-
- '
- '
- ' Union creates a new permission that is the union of the current permission and
- ' the specified permission.
- Private Shared Function UnionDemo() As Boolean
-
- Dim returnValue As Boolean = True
- readPerm3 = CType(readPerm1.Union(readPerm2), RegistryPermission)
-
- If readPerm3 Is Nothing Then
- Console.WriteLine("The union of " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Read) + " " + vbLf + "and " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + " is null.")
- Else
- Console.WriteLine("The union of " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Read) + " " + vbLf + "and " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + " = " + vbLf + vbTab + CType(readPerm3, RegistryPermission).GetPathList(RegistryPermissionAccess.Read).ToString())
- End If
-
- Return returnValue
-
- End Function 'UnionDemo
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the
- ' current permission and the permission specified.
- Private Shared Function IntersectDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- readPerm3 = CType(readPerm1.Intersect(readPerm2), RegistryPermission)
- If Not (readPerm3 Is Nothing) AndAlso Not (readPerm3.GetPathList(RegistryPermissionAccess.Read) Is Nothing) Then
-
- Console.WriteLine("The intersection of " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Read) + " " + vbLf + "and " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + " = " + vbLf + vbTab + CType(readPerm3, RegistryPermission).GetPathList(RegistryPermissionAccess.Read).ToString())
- Else
- Console.WriteLine("The intersection of " + vbLf + readPerm2.GetPathList(RegistryPermissionAccess.Read) + " " + vbLf + "and " + readPerm2.GetPathList(RegistryPermissionAccess.Read) + " is null. ")
- End If
-
- Return returnValue
-
- End Function 'IntersectDemo
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Shared Function CopyDemo() As Boolean
-
- Dim returnValue As Boolean = True
- readPerm4 = CType(readPerm1.Copy(), RegistryPermission)
- If Not (readPerm4 Is Nothing) Then
- Console.WriteLine("Result of copy = " + readPerm4.ToXml().ToString() + vbLf)
- Else
- Console.WriteLine("Result of copy is null. " + vbLf)
- End If
- Return returnValue
-
- End Function 'CopyDemo
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml
- ' reconstructs a permission with the specified state from the XML encoding.
- Private Shared Function ToFromXmlDemo() As Boolean
-
- Dim returnValue As Boolean = True
- '
- readPerm2 = New RegistryPermission(PermissionState.None)
- readPerm2.FromXml(readPerm1.ToXml())
- Console.WriteLine("Result of ToFromXml = " + readPerm2.ToString() + vbLf)
- '
-
- Return returnValue
-
- End Function 'ToFromXmlDemo
-
- '
- '
- ' AddPathList adds access for the specified registry variables to the existing state of the permission.
- ' SetPathList sets new access for the specified registry variable names to the existing state of the permission.
- ' GetPathList gets paths for all registry variables with the specified RegistryPermissionAccess.
- Private Shared Function SetGetPathListDemo() As Boolean
- Try
- Console.WriteLine("********************************************************" + vbLf)
- '
- Dim readPerm1 As RegistryPermission
- Console.WriteLine("Creating RegistryPermission with AllAccess rights for 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0'")
- readPerm1 = New RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
- '
- Console.WriteLine("Adding 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION' to the write access list, " + "and " + vbLf + " 'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0' " + "to the read access list.")
- readPerm1.AddPathList(RegistryPermissionAccess.Write, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION")
- readPerm1.AddPathList(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\FloatingPointProcessor\0")
- Console.WriteLine("Read access list before SetPathList = " + readPerm1.GetPathList(RegistryPermissionAccess.Read))
- Console.WriteLine("Setting read access rights to " + vbLf + "'HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0'")
- readPerm1.SetPathList(RegistryPermissionAccess.Read, "HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\CentralProcessor\0")
- Console.WriteLine("Read access list after SetPathList = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Read))
- Console.WriteLine("Write access = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.Write))
- Console.WriteLine("Write access Registry variables = " + vbLf + readPerm1.GetPathList(RegistryPermissionAccess.AllAccess))
- Catch e As ArgumentException
- ' RegistryPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
- Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. " + _
- "AllAccess cannot be used as a parameter in GetPathList because it represents more than one " + _
- "type of registry variable access : " + vbLf + e.Message)
- End Try
-
- Return True
-
- End Function 'SetGetPathListDemo
-
- '
-
-End Class
-
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb
deleted file mode 100644
index a65337bbf06..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.SecurityPermissionAttribute/VB/securitypermissionattribute.vb
+++ /dev/null
@@ -1,324 +0,0 @@
-'
-' This sample demonstrates the use of the SecurityPermissionAttribute.
-Imports System.Security.Permissions
-Imports System.Security
-
-Class [MyClass]
-
- Public Shared Sub PermissionDemo()
- Try
- DenySecurityPermissions()
- DenyAllSecurityPermissions()
- DoNotDenySecurityPermissions()
- Catch e As Exception
- Console.WriteLine(e.Message.ToString())
- End Try
- End Sub
-
-
-
-
- ' This method demonstrates the use of the SecurityPermissionAttribute to deny individual security permissions.
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- ' Set the Assertion,UnmanagedCode, ControlAppDomain, ControlDomainPolicy, ontrolEvidence,
- ' ControlPolicy, ControlPrincipal, ControlThread, Execution, Flags, Infrastructure,
- ' RemotingConfiguration, SerializationFormatter, and SkipVerification properties.
- _
- Public Shared Sub DenySecurityPermissions()
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- '
- Console.WriteLine("Executing DenySecurityPermissions.")
- Console.WriteLine("Denied all permissions individually.")
- TestSecurityPermissions()
- End Sub
-
-
- ' This method demonstrates the use of SecurityPermissionFlag.AllFlags to deny all security permissions.
- _
- Public Shared Sub DenyAllSecurityPermissions()
- Console.WriteLine(ControlChars.Lf & "Executing DenyAllSecurityPermissions.")
- Console.WriteLine("Denied all permissions using SecurityPermissionFlag.AllFlags.")
- TestSecurityPermissions()
- End Sub
-
-
- ' This method demonstrates the effect of not denying security permissions.
- Public Shared Sub DoNotDenySecurityPermissions()
- Console.WriteLine(ControlChars.Lf & "Executing DoNotDenySecurityPermissions.")
- Console.WriteLine("No permissions have been denied.")
- DemandSecurityPermissions()
- End Sub
-
-
- Public Shared Sub TestSecurityPermissions()
- Console.WriteLine(ControlChars.Lf & "Executing TestSecurityPermissions." & ControlChars.Lf)
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Assertion)
- Console.WriteLine("Demanding SecurityPermissionFlag.Assertion")
- ' This demand should cause an exception.
- sp.Demand()
- ' The TestFailed method is called if an exception is not thrown.
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Assertion failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlAppDomain)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlAppDomain")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlAppDomain failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlDomainPolicy)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlDomainPolicy")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlDomainPolicy failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlEvidence)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlEvidence")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlEvidence failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPolicy)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlPolicy")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPolicy failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPrincipal)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlPrincipal")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPrincipal failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlThread)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlThread")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlThread failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Execution)
- Console.WriteLine("Demanding SecurityPermissionFlag.Execution")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Execution failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Infrastructure)
- Console.WriteLine("Demanding SecurityPermissionFlag.Infrastructure")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Infrastructure failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.RemotingConfiguration)
- Console.WriteLine("Demanding SecurityPermissionFlag.RemotingConfiguration")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.RemotingConfiguration failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.SerializationFormatter)
- Console.WriteLine("Demanding SecurityPermissionFlag.SerializationFormatter")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.SerializationFormatter failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.SkipVerification)
- Console.WriteLine("Demanding SecurityPermissionFlag.SkipVerification")
- sp.Demand()
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.SkipVerification failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
- Console.WriteLine("Demanding SecurityPermissionFlag.UnmanagedCode")
- ' This demand should cause an exception.
- sp.Demand()
- ' The TestFailed method is called if an exception is not thrown.
- TestFailed()
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.UnmanagedCode failed: " & e.Message))
- End Try
- End Sub
-
-
- Public Shared Sub TestFailed()
- Console.WriteLine("In TestFailed method.")
- Console.WriteLine("Throwing an exception.")
- Throw New Exception()
- End Sub
-
-'
- Public Shared Sub DemandSecurityPermissions()
- Console.WriteLine(ControlChars.Lf & "Executing DemandSecurityPermissions." & ControlChars.Lf)
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Assertion)
- Console.WriteLine("Demanding SecurityPermissionFlag.Assertion")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.Assertion succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Assertion failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlAppDomain)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlAppDomain")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlAppDomain succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlAppDomain failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlDomainPolicy)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlDomainPolicy")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlDomainPolicy succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlDomainPolicy failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlEvidence)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlEvidence")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlEvidence succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlEvidence failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPolicy)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlPolicy")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlPolicy succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPolicy failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlPrincipal)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlPrincipal")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlPrincipal succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlPrincipal failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.ControlThread)
- Console.WriteLine("Demanding SecurityPermissionFlag.ControlThread")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.ControlThread succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.ControlThread failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Execution)
- Console.WriteLine("Demanding SecurityPermissionFlag.Execution")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.Execution succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Execution failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.Infrastructure)
- Console.WriteLine("Demanding SecurityPermissionFlag.Infrastructure")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.Infrastructure succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.Infrastructure failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.RemotingConfiguration)
- Console.WriteLine("Demanding SecurityPermissionFlag.RemotingConfiguration")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.RemotingConfiguration succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.RemotingConfiguration failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.SerializationFormatter)
- Console.WriteLine("Demanding SecurityPermissionFlag.SerializationFormatter")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.SerializationFormatter succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.SerializationFormatter failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.SkipVerification)
- Console.WriteLine("Demanding SecurityPermissionFlag.SkipVerification")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.SkipVerification succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.SkipVerification failed: " & e.Message))
- End Try
- Try
- Dim sp As New SecurityPermission(SecurityPermissionFlag.UnmanagedCode)
- Console.WriteLine("Demanding SecurityPermissionFlag.UnmanagedCode")
- sp.Demand()
- Console.WriteLine("Demand for SecurityPermissionFlag.UnmanagedCode succeeded.")
- Catch e As Exception
- Console.WriteLine(("Demand for SecurityPermissionFlag.UnmanagedCode failed: " & e.Message))
- End Try
- End Sub
-'
-
- Overloads Shared Sub Main(ByVal args() As String)
- PermissionDemo()
- End Sub
-End Class
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/VB/program.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/VB/program.vb
deleted file mode 100644
index 2b60999eab2..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StorePermission/VB/program.vb
+++ /dev/null
@@ -1,125 +0,0 @@
-'
-Imports System.Security.Permissions
-Imports System.Security.Cryptography
-Imports System.Security.Cryptography.X509Certificates
-Imports System.Security
-Imports System.IO
-
-
-
-Public Class X509store2
-
- Public Shared Sub Main(ByVal args() As String)
- '
- Console.WriteLine("Creating a permission with Flags = OpenStore.")
- Dim sp As New System.Security.Permissions.StorePermission(StorePermissionFlags.OpenStore)
- '
- 'Create a new X509 store named teststore from the local certificate store.
- 'You must put in a valid path to a certificate in the following constructor.
- Dim certificate As New X509Certificate2("c:\certificates\*****.cer")
- ' Deny the permission to open a store.
- sp.Deny()
- ' The following code results in an exception due to an attempt to open a store.
- AddToStore(certificate)
- ' Remove the deny for opening a store.
- CodeAccessPermission.RevertDeny()
- ' The following code results in an exception due to an attempt to add a certificate.
- ' The exception is thrown due to a StorePermissionAttribute on the method denying AddToStore permission.
- AddToStore(certificate)
- ' The current code is not affected by the attribute in the previously called method, so the following
- ' intructions execute without an exception.
- Dim store As New X509Store("teststore", StoreLocation.CurrentUser)
- store.Open(OpenFlags.ReadWrite)
- store.Add(certificate)
-
- ' Demonstrate the behavior of the class members.
- ShowMembers()
-
- Console.WriteLine("Press the Enter key to exit.")
- Console.ReadKey()
- Return
-
- End Sub
-
- '
- 'Deny the permission the ability to add to a store.
- _
- 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
-
- '
- ' The following method is intended to demonstrate only the behavior of
- ' StorePermission class members,and not their practical usage. Most properties
- ' and methods in this class are used for the resolution and enforcement of
- ' security policy by the security infrastructure code.
- Private Shared Sub ShowMembers()
- Console.WriteLine("Creating first permission with Flags = OpenStore.")
-
- Dim sp1 As New System.Security.Permissions.StorePermission(StorePermissionFlags.OpenStore)
-
- Console.WriteLine("Creating second permission with Flags = AllFlags.")
-
- Dim sp2 As New System.Security.Permissions.StorePermission(StorePermissionFlags.AllFlags)
-
- Console.WriteLine("Creating third permission as Unrestricted.")
- '
- Dim sp3 As New System.Security.Permissions.StorePermission(PermissionState.Unrestricted)
- '
- Console.WriteLine("Creating fourth permission with a permission state of none.")
-
- Dim sp4 As New System.Security.Permissions.StorePermission(PermissionState.None)
- '
- Dim rc As Boolean = sp2.IsSubsetOf(sp3)
- Console.WriteLine("Is the permission with complete store access (AllFlags) a subset of " + _
- vbLf + vbTab + "the permission with an Unrestricted permission state? " + _
- IIf(rc, "Yes", "No"))
- rc = sp1.IsSubsetOf(sp2)
- Console.WriteLine("Is the permission with OpenStore access a subset of the permission with " + _
- vbLf + vbTab + "complete store access (AllFlags)? " + IIf(rc, "Yes", "No"))
- '
- '
- rc = sp3.IsUnrestricted()
- Console.WriteLine("Is the third permission unrestricted? " + IIf(rc, "Yes", "No"))
- '
- '
- Console.WriteLine("Copying the second permission to the fourth permission.")
- sp4 = CType(sp2.Copy(), System.Security.Permissions.StorePermission)
- rc = sp4.Equals(sp2)
- Console.WriteLine("Is the fourth permission equal to the second permission? " + _
- IIf(rc, "Yes", "No"))
- '
- '
- Console.WriteLine("Creating the intersection of the second and first permissions.")
- sp4 = CType(sp2.Intersect(sp1), System.Security.Permissions.StorePermission)
- Console.WriteLine("Value of the Flags property is: " + sp4.Flags.ToString())
-
- '
- '
- Console.WriteLine("Creating the union of the second and first permissions.")
- sp4 = CType(sp2.Union(sp1), System.Security.Permissions.StorePermission)
- Console.WriteLine("Result of the union of the second permission with the first: " + _
- sp4.Flags)
-
- '
- '
- Console.WriteLine("Using an XML roundtrip to reset the fourth permission.")
- sp4.FromXml(sp2.ToXml())
- rc = sp4.Equals(sp2)
- Console.WriteLine("Does the XML roundtrip result equal the original permission? " + _
- IIf(rc, "Yes", "No"))
- '
- End Sub
-End Class
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb
deleted file mode 100644
index bc5a4aa5c5b..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.StrongNameIdentityPermission/VB/strongnameidentity.vb
+++ /dev/null
@@ -1,218 +0,0 @@
- '
-Imports System.Security
-Imports System.Security.Permissions
-
-
-
-
-Public Class StrongNameIdentityDemo
- ' Public key
- Private Shared b1 As Byte() = {0, 36, 0, 0, 4, 128, 0, 0, 148, 0, 0, 0, 6, 2, 0, 0, 0, 36, 0, 0, 82, 83, 65, 49, 0, 4, 0, 0, 1, 0, 1, 0, 237, 146, 145, 51, 34, 97, 123, 196, 90, 174, 41, 170, 173, 221, 41, 193, 175, 39, 7, 151, 178, 0, 230, 152, 218, 8, 206, 206, 170, 84, 111, 145, 26, 208, 158, 240, 246, 219, 228, 34, 31, 163, 11, 130, 16, 199, 111, 224, 4, 112, 46, 84, 0, 104, 229, 38, 39, 63, 53, 189, 0, 157, 32, 38, 34, 109, 0, 171, 114, 244, 34, 59, 9, 232, 150, 192, 247, 175, 104, 143, 171, 42, 219, 66, 66, 194, 191, 218, 121, 59, 92, 42, 37, 158, 13, 108, 210, 189, 9, 203, 204, 32, 48, 91, 212, 101, 193, 19, 227, 107, 25, 133, 70, 2, 220, 83, 206, 71, 102, 245, 104, 252, 87, 109, 190, 56, 34, 180}
-
- Private blob As New StrongNamePublicKeyBlob(b1)
- ' Use this version number.
- Private v1 As New Version("1.0.0.0")
-
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Function IsSubsetOfDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
-
- '
- snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
- '
- snIdPerm2 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", New Version("1.0.0.0"))
-
- If snIdPerm1.IsSubsetOf(snIdPerm2) Then
-
- Console.WriteLine("MyCompany.MyDepartment.* is a subset " + "of MyCompany.MyDepartment.MyFile " + vbLf)
- Else
- Console.WriteLine("MyCompany.MyDepartment.*" + " is not a subset of MyCompany.MyDepartment.MyFile " + vbLf)
- End If
-
- Return returnValue
-
- End Function 'IsSubsetOfDemo
-
- '
- '
- ' Union creates a new permission that is the union of the current permission and the specified permission.
- Private Function UnionDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
- Dim snIdPerm3 As IPermission
-
- snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
- snIdPerm2 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", New Version("1.0.0.0"))
-
- snIdPerm3 = CType(snIdPerm1.Union(snIdPerm2), StrongNameIdentityPermission)
-
- Try
- Console.WriteLine("The union of MyCompany.MyDepartment.*" + "and MyCompany.MyDepartment.MyFile is " + CType(snIdPerm3, StrongNameIdentityPermission).Name.ToString())
- Catch e As Exception
- Console.WriteLine("An expected exception was thrown: " + e.Message)
- End Try
-
-
- Return returnValue
-
- End Function 'UnionDemo
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the current
- ' permission and the permission specified.
- Private Function IntersectDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim snIdPerm1, snIdPerm2, snIdPerm3 As StrongNameIdentityPermission
-
- snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
- snIdPerm2 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.MyFile", New Version("1.0.0.0"))
-
- Try
-
- snIdPerm3 = CType(snIdPerm1.Intersect(snIdPerm2), StrongNameIdentityPermission)
-
- Console.WriteLine("The intersection of MyCompany.MyDepartment.*" + "MyCompany.MyDepartment.MyFile is " + CType(snIdPerm3, StrongNameIdentityPermission).Name.ToString())
-
- Catch e As Exception
- Console.WriteLine("An exception was thrown: " + e.ToString())
- returnValue = False
- End Try
-
- Return returnValue
-
- End Function 'IntersectDemo
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Function CopyDemo() As Boolean
- Dim returnValue As Boolean = True
-
- Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
-
- snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
- '
- snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)
- '
- snIdPerm2 = CType(snIdPerm1.Copy(), StrongNameIdentityPermission)
- Console.WriteLine("Result of copy = " + snIdPerm2.ToString() + vbLf)
-
- Return returnValue
-
- End Function 'CopyDemo
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state;
- 'FromXml reconstructs a permission with the specified state from the XML encoding.
- Private Function ToFromXmlDemo() As Boolean
-
- Dim returnValue As Boolean = True
-
- Dim snIdPerm1, snIdPerm2 As StrongNameIdentityPermission
-
- snIdPerm1 = New StrongNameIdentityPermission(blob, "MyCompany.MyDepartment.*", New Version("1.0.0.0"))
- snIdPerm2 = New StrongNameIdentityPermission(PermissionState.None)
- snIdPerm2.FromXml(snIdPerm1.ToXml())
- Console.WriteLine("Result of ToFromXml = " + snIdPerm2.ToString() + vbLf)
-
- Return returnValue
-
- End Function 'ToFromXmlDemo
-
- '
- ' Invoke all demos.
- Public Function runDemo() As Boolean
-
- Dim ret As Boolean = True
- Dim retTmp As Boolean
- ' Call the IsSubsetOf demo.
- retTmp = IsSubsetOfDemo()
- If retTmp Then
- Console.Out.WriteLine("IsSubsetOf demo completed successfully.")
- Else
- Console.Out.WriteLine("IsSubsetOf demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the Union demo.
- retTmp = UnionDemo()
- If retTmp Then
- Console.Out.WriteLine("Union demo completed successfully.")
- Else
- Console.Out.WriteLine("Union demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the Intersect demo.
- retTmp = IntersectDemo()
- If retTmp Then
- Console.Out.WriteLine("Intersect demo completed successfully.")
- Else
- Console.Out.WriteLine("Intersect demo failed.")
- End If
- ret = retTmp AndAlso ret
-
-
- ' Call the Copy demo.
- retTmp = CopyDemo()
- If retTmp Then
- Console.Out.WriteLine("Copy demo completed successfully")
- Else
- Console.Out.WriteLine("Copy demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- ' Call the ToFromXml demo.
- retTmp = ToFromXmlDemo()
- If retTmp Then
- Console.Out.WriteLine("ToFromXml demo completed successfully")
- Else
- Console.Out.WriteLine("ToFromXml demo failed.")
- End If
- ret = retTmp AndAlso ret
-
- Console.WriteLine("********************************************************" + ControlChars.Lf)
-
-
- Return ret
- End Function 'runDemo
-
-
- ' Test harness.
- Public Overloads Shared Sub Main(ByVal args() As [String])
- Try
- Dim democase As New StrongNameIdentityDemo()
- Dim ret As Boolean = democase.runDemo()
- If ret Then
- Console.Out.WriteLine("StrongNameIdentity demo completed successfully.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 100
- Else
- Console.Out.WriteLine("StrongNameIdentity demo failed.")
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End If
- Catch e As Exception
- Console.Out.WriteLine("StrongNameIdentity demo failed.")
- Console.WriteLine(e.ToString())
- Console.Out.WriteLine("Press the Enter key to exit.")
- Dim consoleInput As String = Console.ReadLine()
- System.Environment.ExitCode = 101
- End Try
- End Sub
-End Class
-
-'
-
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb
deleted file mode 100644
index 2c1f8592e95..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UIPermission/VB/uipermission.vb
+++ /dev/null
@@ -1,165 +0,0 @@
-'
-Imports System.Security
-Imports System.Security.Permissions
-
-
-
-Public Class UIPermissionDemo
-
-
- Public Shared Sub Main(ByVal args() As String)
- IsSubsetOfDemo()
- CopyDemo()
- UnionDemo()
- IntersectDemo()
- ToFromXmlDemo()
-
- End Sub
-
-
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Shared Sub IsSubsetOfDemo()
- '
- Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
- '
- Dim uiPerm2 As New UIPermission(UIPermissionWindow.SafeSubWindows)
- CheckIsSubsetOfWindow(uiPerm1, uiPerm2)
- '
- uiPerm1 = New UIPermission(UIPermissionClipboard.AllClipboard)
- '
- uiPerm2 = New UIPermission(UIPermissionClipboard.OwnClipboard)
- CheckIsSubsetOfClipBoard(uiPerm1, uiPerm2)
-
- End Sub
-
- Private Shared Sub CheckIsSubsetOfWindow(ByVal uiPerm1 As UIPermission, ByVal uiPerm2 As UIPermission)
- If uiPerm1.IsSubsetOf(uiPerm2) Then
- Console.WriteLine(uiPerm1.Window.ToString() + " is a subset of " + uiPerm2.Window.ToString())
- Else
- Console.WriteLine(uiPerm1.Window.ToString() + " is not a subset of " + uiPerm2.Window.ToString())
- End If
-
- If uiPerm2.IsSubsetOf(uiPerm1) Then
- Console.WriteLine(uiPerm2.Window.ToString() + " is a subset of " + uiPerm1.Window.ToString())
- Else
- Console.WriteLine(uiPerm2.Window.ToString() + " is not a subset of " + uiPerm1.Window.ToString())
- End If
-
- End Sub
-
- Private Shared Sub CheckIsSubsetOfClipBoard(ByVal uiPerm1 As UIPermission, ByVal uiPerm2 As UIPermission)
- If uiPerm1.IsSubsetOf(uiPerm2) Then
- Console.WriteLine(uiPerm1.Clipboard.ToString() + " is a subset of " + uiPerm2.Clipboard.ToString())
- Else
- Console.WriteLine(uiPerm1.Clipboard.ToString() + " is not a subset of " + uiPerm2.Clipboard.ToString())
- End If
-
- If uiPerm2.IsSubsetOf(uiPerm1) Then
- Console.WriteLine(uiPerm2.Clipboard.ToString() + " is a subset of " + uiPerm1.Clipboard.ToString())
- Else
- Console.WriteLine(uiPerm2.Clipboard.ToString() + " is not a subset of " + uiPerm1.Clipboard.ToString())
- End If
-
- End Sub
-
- '
- '
- ' Union creates a new permission that is the union of the current permission
- ' and the specified permission.
- Private Shared Sub UnionDemo()
- Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
- Dim uiPerm2 As New UIPermission(UIPermissionWindow.SafeSubWindows)
- Dim p3 As UIPermission = CType(uiPerm1.Union(uiPerm2), UIPermission)
- If Not (p3 Is Nothing) Then
- Console.WriteLine("The union of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is " + vbLf + vbTab + p3.Window.ToString() + vbLf)
-
- Else
- Console.WriteLine("The union of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is null." + vbLf)
- End If
-
- End Sub
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the
- ' current permission and the permission specified.
- Private Shared Sub IntersectDemo()
- '
- Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows, UIPermissionClipboard.OwnClipboard)
- '
- Dim uiPerm2 As New UIPermission(UIPermissionWindow.SafeSubWindows, UIPermissionClipboard.NoClipboard)
- Dim p3 As UIPermission = CType(uiPerm1.Intersect(uiPerm2), UIPermission)
-
- Console.WriteLine("The intersection of " + uiPerm1.Window.ToString() + " and " + vbLf + vbTab + uiPerm2.Window.ToString() + " is " + p3.Window.ToString() + vbLf)
- Console.WriteLine("The intersection of " + uiPerm1.Clipboard.ToString() + " and " + vbLf + vbTab + uiPerm2.Clipboard.ToString() + " is " + p3.Clipboard.ToString() + vbLf)
-
- End Sub
-
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Shared Sub CopyDemo()
-
- Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
- '
- Dim uiPerm2 As New UIPermission(PermissionState.None)
- '
- uiPerm2 = CType(uiPerm1.Copy(), UIPermission)
- If Not (uiPerm2 Is Nothing) Then
- Console.WriteLine("The copy succeeded: " + uiPerm2.ToString() + " " + vbLf)
- End If
-
- End Sub
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
- ' permission with the specified state from the XML encoding.
- Private Shared Sub ToFromXmlDemo()
-
-
- Dim uiPerm1 As New UIPermission(UIPermissionWindow.SafeTopLevelWindows)
- Dim uiPerm2 As New UIPermission(PermissionState.None)
- uiPerm2.FromXml(uiPerm1.ToXml())
- Dim result As Boolean = uiPerm2.Equals(uiPerm1)
- If result Then
- Console.WriteLine("Result of ToFromXml = " + uiPerm2.ToString())
- Else
- Console.WriteLine(uiPerm2.ToString())
- Console.WriteLine(uiPerm1.ToString())
- End If
-
- End Sub
-End Class
-'
-
-'
-' This code example creates the following output:
-
-'SafeTopLevelWindows is not a subset of SafeSubWindows
-'SafeSubWindows is a subset of SafeTopLevelWindows
-'AllClipboard is not a subset of OwnClipboard
-'OwnClipboard is a subset of AllClipboard
-'The copy succeeded:
-
-
-'The union of SafeTopLevelWindows and
-' SafeSubWindows is
-' SafeTopLevelWindows
-
-'The intersection of SafeTopLevelWindows and
-' SafeSubWindows is SafeSubWindows
-
-'The intersection of OwnClipboard and
-' NoClipboard is NoClipboard
-
-'Result of ToFromXml =
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb
deleted file mode 100644
index 8f0ab8d9738..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.UrlIdentityPermission/VB/urlidentity.vb
+++ /dev/null
@@ -1,123 +0,0 @@
-'
-Imports System.Security
-Imports System.Security.Permissions
-
-
-
-Public Class UrlIdentityPermissionDemo
-
- Public Shared Sub Main(ByVal args() As String)
- IsSubsetOfDemo()
- CopyDemo()
- IntersectDemo()
- ToFromXmlDemo()
-
- End Sub
-
-
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Shared Sub IsSubsetOfDemo()
- '
- Dim permIdPerm1 As New UrlIdentityPermission("http://www.fourthcoffee.com/process/")
- '
- Dim permIdPerm2 As New UrlIdentityPermission("http://www.fourthcoffee.com/*")
-
- If permIdPerm1.IsSubsetOf(permIdPerm2) Then
- Console.WriteLine(permIdPerm1.Url + " is a subset of " + permIdPerm2.Url)
- Else
- Console.WriteLine(permIdPerm1.Url + " is not a subset of " + permIdPerm2.Url)
- End If
- If permIdPerm2.IsSubsetOf(permIdPerm1) Then
- Console.WriteLine(permIdPerm2.Url + " is a subset of " + permIdPerm1.Url)
- Else
- Console.WriteLine(permIdPerm2.Url + " is not a subset of " + permIdPerm1.Url)
- End If
-
- End Sub
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the
- ' current permission and the permission specified.
- Private Shared Sub IntersectDemo()
-
- Dim permIdPerm1 As New UrlIdentityPermission("http://www.fourthcoffee.com/process/")
- Dim permIdPerm2 As New UrlIdentityPermission("http://www.fourthcoffee.com/*")
- Dim p3 As UrlIdentityPermission = CType(permIdPerm1.Intersect(permIdPerm2), UrlIdentityPermission)
-
- If Not (p3 Is Nothing) Then
- Console.WriteLine("The intersection of " + permIdPerm1.Url + " and " + vbLf + vbTab + permIdPerm2.Url + " is " + p3.Url + vbLf)
-
- Else
- Console.WriteLine("The intersection of " + permIdPerm1.Url + " and " + vbLf + vbTab + permIdPerm2.Url + " is null." + vbLf)
- End If
-
- End Sub
-
-
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Shared Sub CopyDemo()
-
- Dim permIdPerm1 As New UrlIdentityPermission("http://www.fourthcoffee.com/process/*")
- '
- Dim permIdPerm2 As New UrlIdentityPermission(PermissionState.None)
- '
- permIdPerm2 = CType(permIdPerm1.Copy(), UrlIdentityPermission)
- If Not (permIdPerm2 Is Nothing) Then
- Console.WriteLine("The copy succeeded: " + permIdPerm2.ToString() + " " + vbLf)
- End If
-
- End Sub
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
- ' permission with the specified state from the XML encoding.
- Private Shared Sub ToFromXmlDemo()
-
-
- Dim permIdPerm1 As New UrlIdentityPermission("http://www.fourthcoffee.com/process/*")
- Dim permIdPerm2 As New UrlIdentityPermission(PermissionState.None)
- permIdPerm2.FromXml(permIdPerm1.ToXml())
- Dim result As Boolean = permIdPerm2.Equals(permIdPerm1)
- If result Then
- Console.WriteLine("Result of ToFromXml = " + permIdPerm2.ToString())
- Else
- Console.WriteLine(permIdPerm2.ToString())
- Console.WriteLine(permIdPerm1.ToString())
- End If
-
- End Sub
-End Class
-'
-
-'
-' This code example creates the following output:
-
-'http://www.fourthcoffee.com/process/ is a subset of http://www.fourthcoffee.com/
-'*
-'http://www.fourthcoffee.com/* is not a subset of http://www.fourthcoffee.com/pro
-'cess/
-'The copy succeeded:
-
-
-'The union of http://www.fourthcoffee.com/process/ and
-' http://www.fourthcoffee.com/* failed.
-'The operation is ambiguous because the permission represents multiple identities
-'.
-'The intersection of http://www.fourthcoffee.com/process/ and
-' http://www.fourthcoffee.com/* is http://www.fourthcoffee.com/process/
-
-'Result of ToFromXml =
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb
deleted file mode 100644
index 9ea36cf8bd1..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Permissions.ZoneIdentityPermission/VB/zoneidentity.vb
+++ /dev/null
@@ -1,140 +0,0 @@
-'
-Imports System.Security
-Imports System.Security.Permissions
-
-
-
-Public Class ZoneIdentityPermissionDemo
-
- Public Shared Sub Main(ByVal args() As String)
- IsSubsetOfDemo()
- CopyDemo()
- UnionDemo()
- IntersectDemo()
- ToFromXmlDemo()
-
- End Sub
-
-
- '
- ' IsSubsetOf determines whether the current permission is a subset of the specified permission.
- Private Shared Sub IsSubsetOfDemo()
- '
- Dim zoneIdPerm1 As New ZoneIdentityPermission(SecurityZone.Intranet)
- '
- Dim zoneIdPerm2 As New ZoneIdentityPermission(SecurityZone.MyComputer)
-
- If zoneIdPerm1.IsSubsetOf(zoneIdPerm2) Then
- Console.WriteLine(zoneIdPerm1.SecurityZone.ToString() + " is a subset of " + zoneIdPerm2.SecurityZone.ToString())
- Else
- Console.WriteLine(zoneIdPerm1.SecurityZone.ToString() + " is not a subset of " + zoneIdPerm2.SecurityZone.ToString())
- End If
-
- If zoneIdPerm2.IsSubsetOf(zoneIdPerm1) Then
- Console.WriteLine(zoneIdPerm2.SecurityZone.ToString() + " is a subset of " + zoneIdPerm1.SecurityZone.ToString())
- Else
- Console.WriteLine(zoneIdPerm2.SecurityZone.ToString() + " is not a subset of " + zoneIdPerm1.SecurityZone.ToString())
- End If
-
- End Sub
-
- '
- '
- ' Union creates a new permission that is the union of the current permission
- ' and the specified permission.
- Private Shared Sub UnionDemo()
- Dim zoneIdPerm1 As New ZoneIdentityPermission(SecurityZone.Intranet)
- Dim zoneIdPerm2 As New ZoneIdentityPermission(SecurityZone.MyComputer)
- Dim p3 As ZoneIdentityPermission = CType(zoneIdPerm1.Union(zoneIdPerm2), ZoneIdentityPermission)
- If Not (p3 Is Nothing) Then
- Console.WriteLine("The union of " + zoneIdPerm1.SecurityZone.ToString() + " and " + vbLf + vbTab + zoneIdPerm2.SecurityZone.ToString() + " is " + vbLf + vbTab + p3.SecurityZone.ToString() + vbLf)
-
- Else
- Console.WriteLine("The union of " + zoneIdPerm1.SecurityZone.ToString() + " and " + vbLf + vbTab + zoneIdPerm2.SecurityZone.ToString() + " is null." + vbLf)
- End If
-
- End Sub
-
- '
- '
- ' Intersect creates and returns a new permission that is the intersection of the
- ' current permission and the permission specified.
- Private Shared Sub IntersectDemo()
-
- Dim zoneIdPerm1 As New ZoneIdentityPermission(SecurityZone.Intranet)
- Dim zoneIdPerm2 As New ZoneIdentityPermission(SecurityZone.MyComputer)
- Dim p3 As ZoneIdentityPermission = CType(zoneIdPerm1.Intersect(zoneIdPerm2), ZoneIdentityPermission)
-
- If Not (p3 Is Nothing) Then
- Console.WriteLine("The intersection of " + zoneIdPerm1.SecurityZone.ToString() + " and " + vbLf + vbTab + zoneIdPerm2.SecurityZone.ToString() + " is " + p3.SecurityZone.ToString() + vbLf)
-
- Else
- Console.WriteLine("The intersection of " + zoneIdPerm1.SecurityZone.ToString() + " and " + vbLf + vbTab + zoneIdPerm2.SecurityZone.ToString() + " is null." + vbLf)
- End If
-
- End Sub
-
-
-
- '
- '
- 'Copy creates and returns an identical copy of the current permission.
- Private Shared Sub CopyDemo()
-
- Dim zoneIdPerm1 As New ZoneIdentityPermission(SecurityZone.Intranet)
- '
- Dim zoneIdPerm2 As New ZoneIdentityPermission(PermissionState.None)
- '
- zoneIdPerm2 = CType(zoneIdPerm1.Copy(), ZoneIdentityPermission)
- If Not (zoneIdPerm2 Is Nothing) Then
- Console.WriteLine("The copy succeeded: " + zoneIdPerm2.ToString() + " " + vbLf)
- End If
-
- End Sub
-
- '
- '
- ' ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a
- ' permission with the specified state from the XML encoding.
- Private Shared Sub ToFromXmlDemo()
-
-
- Dim zoneIdPerm1 As New ZoneIdentityPermission(SecurityZone.Intranet)
- Dim zoneIdPerm2 As New ZoneIdentityPermission(PermissionState.None)
- zoneIdPerm2.FromXml(zoneIdPerm1.ToXml())
- Dim result As Boolean = zoneIdPerm2.Equals(zoneIdPerm1)
- If result Then
- Console.WriteLine("Result of ToFromXml = " + zoneIdPerm2.ToString())
- Else
- Console.WriteLine(zoneIdPerm2.ToString())
- Console.WriteLine(zoneIdPerm1.ToString())
- End If
-
- End Sub
-End Class
-'
-
-'
-' This code example creates the following output:
-
-'Intranet is not a subset of MyComputer
-'MyComputer is not a subset of Intranet
-'The copy succeeded:
-
-
-'The union of Intranet and
-' MyComputer is
-' NoZone
-
-'The intersection of Intranet and
-' MyComputer is null.
-
-'Result of ToFromXml =
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb
deleted file mode 100644
index 13679441c98..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FileCodeGroup_Evt/VB/Form1.vb
+++ /dev/null
@@ -1,456 +0,0 @@
-' This sample demonstrates how to use each member of the FileCodeGroup class.
-'
-Imports System.Security
-Imports System.Security.Policy
-Imports System.Security.Permissions
-Imports System.Reflection
-Imports System.Windows.Forms
-
-Public Class Form1
- Inherits System.Windows.Forms.Form
-
- ' Event handler for Run button.
- Private Sub Button1_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button1.Click
-
- tbxOutput.Cursor = Cursors.WaitCursor
- tbxOutput.Text = ""
-
- Dim fileCodeGroup As FileCodeGroup = constructDefaultGroup()
-
- ' Create a deep copy of the FileCodeGroup;
- '
- Dim copyCodeGroup As FileCodeGroup = _
- CType(fileCodeGroup.Copy(), FileCodeGroup)
- '
-
- CompareTwoCodeGroups(fileCodeGroup, copyCodeGroup)
-
- addPolicy(fileCodeGroup)
- addXmlMember(fileCodeGroup)
- updateMembershipCondition(fileCodeGroup)
- addChildCodeGroup(fileCodeGroup)
-
- WriteLine("Comparing the resolved code group with the initial " + _
- "code group:")
- Dim resolvedCodeGroup As FileCodeGroup
- resolvedCodeGroup = ResolveGroupToEvidence(fileCodeGroup)
-
- If (CompareTwoCodeGroups(fileCodeGroup, resolvedCodeGroup)) Then
- PrintCodeGroup(resolvedCodeGroup)
- Else
- PrintCodeGroup(fileCodeGroup)
- End If
-
- ' Reset the cursor and conclude application.
- tbxOutput.AppendText(vbCrLf + "This sample completed " + _
- "successfully; press Exit to continue.")
- tbxOutput.Cursor = Cursors.Default
- End Sub
- ' Construct a new FileCodeGroup with read, write, append and
- ' discovery access.
- Private Function constructDefaultGroup() As FileCodeGroup
- ' Construct a file code group with read, write, append and
- ' discovery access.
- '
- Dim fileCodeGroup As New FileCodeGroup( _
- New AllMembershipCondition, _
- FileIOPermissionAccess.AllAccess)
- '
-
- ' Set the name of the file code group.
- '
- fileCodeGroup.Name = "TempCodeGroup"
- '
-
- ' Set the description of the file code group.
- '
- fileCodeGroup.Description = "Temp folder permissions group"
- '
-
- ' Retrieve the string representation of the Policy's attributes.
- ' FileCodeGroup does not use AttributeString, so the value should
- ' be null.
- '
- If (Not fileCodeGroup.AttributeString Is Nothing) Then
- Throw New NullReferenceException( _
- "AttributeString property is not empty")
- End If
- '
-
- Return fileCodeGroup
- End Function
-
- ' Add file permission to restrict write access to all files on the
- ' local machine.
- Private Sub addPolicy(ByRef fileCodeGroup As FileCodeGroup)
- ' Set the PolicyStatement property to a policy with
- ' read access to c:\.
- '
- Dim rootFilePermissions As New FileIOPermission(PermissionState.None)
- rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read
- rootFilePermissions.SetPathList(FileIOPermissionAccess.Read, "C:\\")
-
- Dim namedPermissions As New NamedPermissionSet("RootPermissions")
- namedPermissions.AddPermission(rootFilePermissions)
-
- fileCodeGroup.PolicyStatement = New PolicyStatement(namedPermissions)
- '
- End Sub
-
- ' Set the membership condition of the specified FileCodeGroup to
- ' Intranet zone.
- Private Sub updateMembershipCondition( _
- ByRef fileCodeGroup As FileCodeGroup)
-
- ' Set the membership condition to the Intranet zone.
- '
- Dim zoneCondition As _
- New ZoneMembershipCondition(SecurityZone.Intranet)
-
- fileCodeGroup.MembershipCondition = zoneCondition
- '
- End Sub
-
- ' Add a child group with read-access file permissions to the specified
- ' code group.
- Private Sub addChildCodeGroup(ByRef fileCodeGroup As FileCodeGroup)
- ' Create a file code group with read access.
- '
- Dim tempFolderCodeGroup As New FileCodeGroup( _
- New AllMembershipCondition, _
- FileIOPermissionAccess.Read)
-
- ' Set the name of the child code group and add it to the specified
- ' code group.
- tempFolderCodeGroup.Name = "Read-only group"
- fileCodeGroup.AddChild(tempFolderCodeGroup)
- '
- End Sub
-
- ' Compare two specified FileCodeGroups for equality.
- Private Function CompareTwoCodeGroups( _
- ByVal firstCodeGroup As FileCodeGroup, _
- ByVal secondCodeGroup As FileCodeGroup) As Boolean
-
- ' Compare two FileCodeGroups for equality.
- '
- If (firstCodeGroup.Equals(secondCodeGroup)) Then
- '
- WriteLine("The two code groups are equal.")
- Return True
- Else
- WriteLine("The two code groups are not equal.")
- Return False
- End If
-
- End Function
-
- ' Retrieve the resolved policy based on the executing evidence found
- ' in the specified code group.
- Private Function ResolveEvidence( _
- ByVal fileCodeGroup As CodeGroup) As String
-
- Dim policyString As String = ""
-
- ' Resolve the policy based on the executing assemlby's evidence.
- '
- Dim executingAssembly As [Assembly]
- executingAssembly = Me.GetType().Assembly
-
- Dim executingEvidence As Evidence = executingAssembly.Evidence
-
- Dim policy As PolicyStatement
- policy = fileCodeGroup.Resolve(executingEvidence)
- '
-
- If (Not policy Is Nothing) Then
- policyString = policy.ToString()
- End If
-
- Return policyString
- End Function
-
- ' Retrieve the resolved code group based on the executing evidence found
- ' in the specified code group.
- Private Function ResolveGroupToEvidence( _
- ByVal fileCodeGroup As FileCodeGroup) As FileCodeGroup
-
- ' Resolve matching code groups to the executing assembly.
- '
- Dim executingAssembly As [Assembly]
- executingAssembly = Me.GetType().Assembly
-
- Dim evidence As Evidence = executingAssembly.Evidence
-
- Dim codeGroup As CodeGroup
- codeGroup = fileCodeGroup.ResolveMatchingCodeGroups(evidence)
- '
-
- Return CType(codeGroup, FileCodeGroup)
- End Function
-
- ' If domain attribute is not found in specified FileCodeGroup,
- ' add a child Xml element identifying a custom membership condition.
- Private Sub addXmlMember(ByRef fileCodeGroup As FileCodeGroup)
- '
- Dim xmlElement As SecurityElement = fileCodeGroup.ToXml()
- '
-
- Dim rootElement As New SecurityElement("CodeGroup")
- If (xmlElement.Attribute("domain") Is Nothing) Then
- '
- Dim newElement As New SecurityElement("CustomMembershipCondition")
- newElement.AddAttribute("class", "CustomMembershipCondition")
- newElement.AddAttribute("version", "1")
- newElement.AddAttribute("domain", "contoso.com")
-
- rootElement.AddChild(newElement)
-
- fileCodeGroup.FromXml(rootElement)
- '
-
- End If
-
- WriteLine("Added a custom membership condition:")
- WriteLine(rootElement.ToString())
- End Sub
-
- ' Print the properties of the specified code group to the output textbox.
- Private Sub PrintCodeGroup(ByVal codeGroup As CodeGroup)
- ' Compare specified object's type with the FileCodeGroup type.
- '
- If (Not codeGroup.GetType() Is GetType(FileCodeGroup)) Then
- '
- Throw New ArgumentException("Excepted FileCodeGroup type")
- End If
-
- Dim codeGroupName As String = codeGroup.Name
- Dim membershipCondition As String
- membershipCondition = codeGroup.MembershipCondition.ToString()
-
- '
- Dim permissionSetName As String = codeGroup.PermissionSetName
- '
-
- '
- Dim hashCode As Integer = codeGroup.GetHashCode()
- '
-
- Dim mergeLogic As String = ""
- '
- If (codeGroup.MergeLogic.Equals("Union")) Then
- '
- mergeLogic = " with Union merge logic"
- End If
-
- ' Retrieve the class path for FileCodeGroup.
- '
- Dim fileGroupClass As String = codeGroup.ToString()
- '
-
- ' Write summary to console window.
- WriteLine(vbCrLf + "*** " + fileGroupClass + " summary ***")
- Write("A FileCodeGroup named " + codeGroupName + mergeLogic)
- Write(" has been created with hash code(" + hashCode.ToString())
- Write("). It contains a " + membershipCondition)
- Write(" membership condition with the ")
- Write(permissionSetName + " permission set. ")
-
- WriteLine("It has the following policy: " + _
- ResolveEvidence(codeGroup))
- Dim childCount As Integer = codeGroup.Children.Count
- If (childCount > 0) Then
- Write("There are " + childCount.ToString())
- WriteLine(" child elements in the code group:")
-
- ' Iterate through the child code groups to display their names and
- ' remove them from the specified code group.
- For i As Int16 = 0 To childCount - 1 Step 1
- ' Get child code group as type FileCodeGroup.
- '
- Dim childCodeGroup As FileCodeGroup
- childCodeGroup = CType(codeGroup.Children(i), FileCodeGroup)
- '
-
- Write("Removing the " + childCodeGroup.Name + ".")
- ' Remove child codegroup.
- '
- codeGroup.RemoveChild(childCodeGroup)
- '
- Next
-
- WriteLine("")
-
- Else
- WriteLine("There are no children found in the code group:")
-
- End If
- End Sub
- ' Write message to the output textbox.
- Private Sub Write(ByVal message As String)
- tbxOutput.AppendText(message)
-
- End Sub
- ' Write message with carriage return to the output textbox.
- Private Sub WriteLine(ByVal message As String)
- tbxOutput.AppendText(message + vbCrLf)
-
- End Sub
-
-
- ' Event handler for Exit button.
- Private Sub Button2_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button2.Click
-
- Application.Exit()
- End Sub
-#Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.IContainer
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- Friend WithEvents Panel2 As System.Windows.Forms.Panel
- Friend WithEvents Panel1 As System.Windows.Forms.Panel
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents Button2 As System.Windows.Forms.Button
- Friend WithEvents tbxOutput As System.Windows.Forms.RichTextBox
- _
- Private Sub InitializeComponent()
- Me.Panel2 = New System.Windows.Forms.Panel
- Me.Button1 = New System.Windows.Forms.Button
- Me.Button2 = New System.Windows.Forms.Button
- Me.Panel1 = New System.Windows.Forms.Panel
- Me.tbxOutput = New System.Windows.Forms.RichTextBox
- Me.Panel2.SuspendLayout()
- Me.Panel1.SuspendLayout()
- Me.SuspendLayout()
- '
- 'Panel2
- '
- Me.Panel2.Controls.Add(Me.Button1)
- Me.Panel2.Controls.Add(Me.Button2)
- Me.Panel2.Dock = System.Windows.Forms.DockStyle.Bottom
- Me.Panel2.DockPadding.All = 20
- Me.Panel2.Location = New System.Drawing.Point(0, 320)
- Me.Panel2.Name = "Panel2"
- Me.Panel2.Size = New System.Drawing.Size(616, 64)
- Me.Panel2.TabIndex = 1
- '
- 'Button1
- '
- Me.Button1.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button1.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button1.Location = New System.Drawing.Point(446, 20)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(75, 24)
- Me.Button1.TabIndex = 2
- Me.Button1.Text = "&Run"
- '
- 'Button2
- '
- Me.Button2.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button2.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button2.Location = New System.Drawing.Point(521, 20)
- Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(75, 24)
- Me.Button2.TabIndex = 3
- Me.Button2.Text = "E&xit"
- '
- 'Panel1
- '
- Me.Panel1.Controls.Add(Me.tbxOutput)
- Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
- Me.Panel1.DockPadding.All = 20
- Me.Panel1.Location = New System.Drawing.Point(0, 0)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(616, 320)
- Me.Panel1.TabIndex = 2
- '
- 'tbxOutput
- '
- Me.tbxOutput.AccessibleDescription = _
- "Displays output from application."
- Me.tbxOutput.AccessibleName = "Output textbox."
- Me.tbxOutput.Dock = System.Windows.Forms.DockStyle.Fill
- Me.tbxOutput.Location = New System.Drawing.Point(20, 20)
- Me.tbxOutput.Name = "tbxOutput"
- Me.tbxOutput.Size = New System.Drawing.Size(576, 280)
- Me.tbxOutput.TabIndex = 1
- Me.tbxOutput.Text = "Click the Run button to run the application."
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
- Me.ClientSize = New System.Drawing.Size(616, 384)
- Me.Controls.Add(Me.Panel1)
- Me.Controls.Add(Me.Panel2)
- Me.Name = "Form1"
- Me.Text = "FileCodeGroup"
- Me.Panel2.ResumeLayout(False)
- Me.Panel1.ResumeLayout(False)
- Me.ResumeLayout(False)
-
- End Sub
-
-#End Region
-End Class
-'
-' This sample produces the following output:
-'
-' The two code groups are equal.
-' Added a custom membership condition:
-'
-'
-'
-'
-' Comparing the resolved code group with the initial code group:
-' The two code groups are not equal.
-'
-' *** System.Security.Policy.FileCodeGroup summary ***
-' A FileCodeGroup named with Union merge logic has been created with hash
-' code (113152269). It contains a Zone - Intranet membership condition with
-' the Same directory FileIO - NoAccess permission set. Has the following
-' policy:
-' There are 1 child elements in the code group:
-' Removing the Read-only group.
-'
-' This sample completed successfully; press Exit to continue.
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb
deleted file mode 100644
index 6f40ed3bab3..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.FirstMatchCodeGroup_Evt/VB/Form1.vb
+++ /dev/null
@@ -1,487 +0,0 @@
-' This sample demonstrates how to use each member of the FirstMatchCodeGroup
-' class.
-'
-Imports System.Security
-Imports System.Security.Policy
-Imports System.Security.Permissions
-Imports System.Reflection
-Imports System.Windows.Forms
-
-Public Class Form1
- Inherits System.Windows.Forms.Form
-
- ' Event handler for Run button.
- Private Sub Button1_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button1.Click
-
- tbxOutput.Cursor = Cursors.WaitCursor
- tbxOutput.Text = ""
-
- ' Create a new FirstMatchCodeGroup.
- Dim codeGroup As FirstMatchCodeGroup = constructDefaultGroup()
-
- ' Create a deep copy of the FirstMatchCodeGroup.
- '
- Dim copyCodeGroup As FirstMatchCodeGroup
- copyCodeGroup = CType(codeGroup.Copy(), FirstMatchCodeGroup)
- '
-
- ' Compare the original code group with the copy.
- CompareTwoCodeGroups(codeGroup, copyCodeGroup)
-
- addPolicy(codeGroup)
- addXmlMember(codeGroup)
- updateMembershipCondition(codeGroup)
- addChildCodeGroup(codeGroup)
-
- Write("Comparing the resolved code group ")
- WriteLine("with the initial code group.")
-
- Dim resolvedCodeGroup As FirstMatchCodeGroup
- resolvedCodeGroup = ResolveGroupToEvidence(codeGroup)
- If (CompareTwoCodeGroups(codeGroup, resolvedCodeGroup)) Then
- PrintCodeGroup(resolvedCodeGroup)
- Else
- PrintCodeGroup(codeGroup)
- End If
-
- ' Reset the cursor and conclude application.
- tbxOutput.AppendText(vbCrLf + "This sample completed " + _
- "successfully; press Exit to continue.")
- tbxOutput.Cursor = Cursors.Default
- End Sub
- ' Create a FirstMatchCodeGroup with an exclusive policy and membership
- ' condition.
- Private Function constructDefaultGroup() As FirstMatchCodeGroup
- ' Construct a new FirstMatchCodeGroup with Read, Write, Append
- ' and PathDiscovery access.
- ' Create read access permission to the root directory on drive C.
- '
- Dim rootFilePermissions As New FileIOPermission(PermissionState.None)
- rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read
- rootFilePermissions.SetPathList(FileIOPermissionAccess.Read, "C:\\")
-
- ' Add a permission to a named permission set.
- Dim namedPermissions As New NamedPermissionSet("RootPermissions")
- namedPermissions.AddPermission(rootFilePermissions)
-
- ' Create a PolicyStatement with exclusive rights to the policy.
- Dim policy As New PolicyStatement( _
- namedPermissions, _
- PolicyStatementAttribute.Exclusive)
-
- ' Create a FirstMatchCodeGroup with a membership condition that
- ' matches all code, and an exclusive policy.
- Dim codeGroup As New FirstMatchCodeGroup( _
- New AllMembershipCondition, _
- policy)
- '
-
- ' Set the name of the first match code group.
- '
- codeGroup.Name = "TempCodeGroup"
- '
-
- ' Set the description of the first match code group.
- '
- codeGroup.Description = "Temp folder permissions group"
- '
-
- Return codeGroup
- End Function
-
- ' Add file permission to restrict write access to all files
- ' on the local machine.
- Private Sub addPolicy(ByRef codeGroup As FirstMatchCodeGroup)
- ' Set the PolicyStatement property to a policy with read access to the
- ' root directory on drive C.
- '
- Dim rootFilePermissions As New FileIOPermission(PermissionState.None)
- rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read
- rootFilePermissions.SetPathList(FileIOPermissionAccess.Read, "C:\\")
-
- Dim namedPermissions As New NamedPermissionSet("RootPermissions")
- namedPermissions.AddPermission(rootFilePermissions)
-
- ' Create a PolicyStatement with exclusive rights to the policy.
- Dim policy As New PolicyStatement( _
- namedPermissions, _
- PolicyStatementAttribute.Exclusive)
-
- codeGroup.PolicyStatement = policy
- '
- End Sub
-
- ' Set the membership condition of the code group.
- Private Sub updateMembershipCondition( _
- ByRef codeGroup As FirstMatchCodeGroup)
-
- ' Set the membership condition of the specified FirstMatchCodeGroup
- ' to the Intranet zone.
- '
- Dim zoneCondition As _
- New ZoneMembershipCondition(SecurityZone.Intranet)
- codeGroup.MembershipCondition = zoneCondition
- '
- End Sub
-
- ' Create a child code group with read-access file permissions and add it
- ' to the specified code group.
- Private Sub addChildCodeGroup(ByRef codegroup As FirstMatchCodeGroup)
- ' Create a first match code group with read access.
- '
- Dim rootFilePermissions As New FileIOPermission(PermissionState.None)
- rootFilePermissions.AllLocalFiles = FileIOPermissionAccess.Read
- rootFilePermissions.SetPathList(FileIOPermissionAccess.Read, "C:\\")
-
- Dim permissions As New PermissionSet(PermissionState.Unrestricted)
- permissions.AddPermission(rootFilePermissions)
-
- Dim tempFolderCodeGroup = New FirstMatchCodeGroup( _
- New AllMembershipCondition, _
- New PolicyStatement(permissions))
-
- ' Set the name of the child code group and add it to the specified
- ' code group.
- tempFolderCodeGroup.Name = "Read-only code group"
- codegroup.AddChild(tempFolderCodeGroup)
- '
- End Sub
-
- ' Compare the two FirstMatchCodeGroups.
- Private Function CompareTwoCodeGroups( _
- ByVal firstCodeGroup As FirstMatchCodeGroup, _
- ByVal secondCodeGroup As FirstMatchCodeGroup) As Boolean
-
- ' Compare the two specified FirstMatchCodeGroups for equality.
- '
- If (firstCodeGroup.Equals(secondCodeGroup)) Then
- '
-
- WriteLine("The two code groups are equal.")
- Return True
- Else
- WriteLine("The two code groups are not equal.")
- Return False
- End If
- End Function
-
- ' Retrieve the resolved policy based on executing evidence found
- ' in the specified code group.
- Private Function ResolveEvidence(ByVal codeGroup As CodeGroup) As String
- Dim policyString As String = "None"
-
- ' Resolve the policy based on the executing assembly's evidence.
- '
- Dim executingAssembly As [Assembly] = Me.GetType().Assembly
- Dim executingEvidence As Evidence
- executingEvidence = executingAssembly.Evidence
-
- Dim policy As PolicyStatement = codeGroup.Resolve(executingEvidence)
- '
-
- If (Not policy Is Nothing) Then
- policyString = policy.ToString()
- End If
-
- Return policyString
- End Function
-
- ' Retrieve the resolved code group based on the evidence from the
- ' specified code group.
- Private Function ResolveGroupToEvidence( _
- ByVal codegroup As FirstMatchCodeGroup) _
- As FirstMatchCodeGroup
-
- ' Resolve matching code groups to the executing assembly.
- '
- Dim executingAssembly As [Assembly] = Me.GetType().Assembly
- Dim evidence As Evidence = executingAssembly.Evidence
- Dim resolvedCodeGroup As CodeGroup
- resolvedCodeGroup = codegroup.ResolveMatchingCodeGroups(Evidence)
- '
-
- Return CType(resolvedCodeGroup, FirstMatchCodeGroup)
- End Function
-
- ' If a domain attribute is not found in the specified FirstMatchCodeGroup,
- ' add a child XML element identifying a custom membership condition.
- Private Sub addXmlMember(ByRef codeGroup As FirstMatchCodeGroup)
- '
- Dim xmlElement As SecurityElement = codeGroup.ToXml()
- '
-
- Dim rootElement As New SecurityElement("CodeGroup")
-
- If (xmlElement.Attribute("domain") Is Nothing) Then
- '
- Dim newElement As New SecurityElement("CustomMembershipCondition")
- newElement.AddAttribute("class", "CustomMembershipCondition")
- newElement.AddAttribute("version", "1")
- newElement.AddAttribute("domain", "contoso.com")
-
- rootElement.AddChild(newElement)
-
- codeGroup.FromXml(rootElement)
- '
- End If
-
- WriteLine("Added a custom membership condition:")
- WriteLine(rootElement.ToString())
- End Sub
-
- ' Print the properties of the specified code group to the console.
- Private Sub PrintCodeGroup(ByVal codeGroup As CodeGroup)
- ' Compare the type of the specified object with the
- ' FirstMatchCodeGroup type.
- '
- If (Not codeGroup.GetType() Is GetType(FirstMatchCodeGroup)) Then
- '
- Throw New ArgumentException( _
- "Expected the FirstMatchCodeGroup type.")
-
- End If
-
- Dim codeGroupName As String = codeGroup.Name
- Dim membershipCondition As String
- membershipCondition = codeGroup.MembershipCondition.ToString()
-
- '
- Dim permissionSetName As String = codeGroup.PermissionSetName
- '
-
- '
- Dim hashCode As Integer = codeGroup.GetHashCode()
- '
-
- Dim mergeLogic As String = ""
- '
- If (codeGroup.MergeLogic.Equals("First Match")) Then
- '
- mergeLogic = "with first-match merge logic"
- End If
-
- ' Retrieve the class path for the FirstMatchCodeGroup.
- '
- Dim firstMatchGroupClass As String = codeGroup.ToString()
- '
-
- Dim attributeString As String = ""
- ' Retrieve the string representation of the FirstMatchCodeGroup's
- ' attributes.
- '
- If (Not codeGroup.AttributeString Is Nothing) Then
- attributeString = codeGroup.AttributeString
- End If
- '
-
- ' Write a summary to the console window.
- WriteLine(vbCrLf + "* " + firstMatchGroupClass + " summary *")
- Write("A FirstMatchCodeGroup named ")
- Write(codeGroupName + mergeLogic)
- Write(" has been created with hash code ")
- WriteLine(hashCode.ToString() + ". ")
-
- Write("This code group contains a " + membershipCondition)
- Write(" membership condition with the ")
- Write(permissionSetName + " permission set. ")
-
- Write("The code group contains the following policy: ")
- Write(ResolveEvidence(codeGroup) + ". ")
- Write("It also contains the following attributes: ")
- WriteLine(attributeString)
-
- Dim childCount As Integer = codeGroup.Children.Count
- If (childCount > 0) Then
- Write("There are " + childCount.ToString())
- WriteLine(" child elements in the code group.")
-
- ' Iterate through the child code groups to display their names
- ' and then remove them from the specified code group.
- For i As Int16 = 0 To childCount - 1 Step 1
- ' Retrieve each child explicitly casted as a
- ' FirstMatchCodeGroup type.
- '
- Dim childCodeGroup As FirstMatchCodeGroup
- childCodeGroup = _
- CType(codeGroup.Children(i), FirstMatchCodeGroup)
- '
-
- Write("Removing the " + childCodeGroup.Name + ".")
- ' Remove the child code group.
- '
- codeGroup.RemoveChild(childCodeGroup)
- '
- Next
-
- WriteLine("")
- Else
- WriteLine("No child code groups were found in this code group.")
- End If
- End Sub
-
- Private Sub WriteLine(ByVal message As String)
- tbxOutput.AppendText(message + vbCrLf)
-
- End Sub
-
- Private Sub Write(ByVal message As String)
- tbxOutput.AppendText(message)
-
- End Sub
-
- ' Event handler for Exit button.
- Private Sub Button2_Click( _
- ByVal sender As System.Object, _
- ByVal e As System.EventArgs) Handles Button2.Click
-
- Application.Exit()
- End Sub
-#Region " Windows Form Designer generated code "
-
- Public Sub New()
- MyBase.New()
-
- 'This call is required by the Windows Form Designer.
- InitializeComponent()
-
- 'Add any initialization after the InitializeComponent() call
-
- End Sub
-
- 'Form overrides dispose to clean up the component list.
- Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
- If disposing Then
- If Not (components Is Nothing) Then
- components.Dispose()
- End If
- End If
- MyBase.Dispose(disposing)
- End Sub
-
- 'Required by the Windows Form Designer
- Private components As System.ComponentModel.IContainer
-
- 'NOTE: The following procedure is required by the Windows Form Designer
- 'It can be modified using the Windows Form Designer.
- 'Do not modify it using the code editor.
- Friend WithEvents Panel2 As System.Windows.Forms.Panel
- Friend WithEvents Panel1 As System.Windows.Forms.Panel
- Friend WithEvents Button1 As System.Windows.Forms.Button
- Friend WithEvents Button2 As System.Windows.Forms.Button
- Friend WithEvents tbxOutput As System.Windows.Forms.RichTextBox
- _
- Private Sub InitializeComponent()
- Me.Panel2 = New System.Windows.Forms.Panel
- Me.Button1 = New System.Windows.Forms.Button
- Me.Button2 = New System.Windows.Forms.Button
- Me.Panel1 = New System.Windows.Forms.Panel
- Me.tbxOutput = New System.Windows.Forms.RichTextBox
- Me.Panel2.SuspendLayout()
- Me.Panel1.SuspendLayout()
- Me.SuspendLayout()
- '
- 'Panel2
- '
- Me.Panel2.Controls.Add(Me.Button1)
- Me.Panel2.Controls.Add(Me.Button2)
- Me.Panel2.Dock = System.Windows.Forms.DockStyle.Bottom
- Me.Panel2.DockPadding.All = 20
- Me.Panel2.Location = New System.Drawing.Point(0, 320)
- Me.Panel2.Name = "Panel2"
- Me.Panel2.Size = New System.Drawing.Size(616, 64)
- Me.Panel2.TabIndex = 1
- '
- 'Button1
- '
- Me.Button1.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button1.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button1.Location = New System.Drawing.Point(446, 20)
- Me.Button1.Name = "Button1"
- Me.Button1.Size = New System.Drawing.Size(75, 24)
- Me.Button1.TabIndex = 2
- Me.Button1.Text = "&Run"
- '
- 'Button2
- '
- Me.Button2.Dock = System.Windows.Forms.DockStyle.Right
- Me.Button2.Font = New System.Drawing.Font( _
- "Microsoft Sans Serif", _
- 9.0!, _
- System.Drawing.FontStyle.Regular, _
- System.Drawing.GraphicsUnit.Point, _
- CType(0, Byte))
- Me.Button2.Location = New System.Drawing.Point(521, 20)
- Me.Button2.Name = "Button2"
- Me.Button2.Size = New System.Drawing.Size(75, 24)
- Me.Button2.TabIndex = 3
- Me.Button2.Text = "E&xit"
- '
- 'Panel1
- '
- Me.Panel1.Controls.Add(Me.tbxOutput)
- Me.Panel1.Dock = System.Windows.Forms.DockStyle.Fill
- Me.Panel1.DockPadding.All = 20
- Me.Panel1.Location = New System.Drawing.Point(0, 0)
- Me.Panel1.Name = "Panel1"
- Me.Panel1.Size = New System.Drawing.Size(616, 320)
- Me.Panel1.TabIndex = 2
- '
- 'tbxOutput
- '
- Me.tbxOutput.AccessibleDescription = _
- "Displays output from application."
- Me.tbxOutput.AccessibleName = "Output textbox."
- Me.tbxOutput.Dock = System.Windows.Forms.DockStyle.Fill
- Me.tbxOutput.Location = New System.Drawing.Point(20, 20)
- Me.tbxOutput.Name = "tbxOutput"
- Me.tbxOutput.Size = New System.Drawing.Size(576, 280)
- Me.tbxOutput.TabIndex = 1
- Me.tbxOutput.Text = "Click the Run button to run the application."
- '
- 'Form1
- '
- Me.AutoScaleBaseSize = New System.Drawing.Size(6, 15)
- Me.ClientSize = New System.Drawing.Size(616, 384)
- Me.Controls.Add(Me.Panel1)
- Me.Controls.Add(Me.Panel2)
- Me.Name = "Form1"
- Me.Text = "FirstMatchCodeGroup"
- Me.Panel2.ResumeLayout(False)
- Me.Panel1.ResumeLayout(False)
- Me.ResumeLayout(False)
-
- End Sub
-
-#End Region
-End Class
-'
-' This sample produces the following output:
-'
-' The two code groups are equal.
-' Added a custom membership condition:
-'
-'
-'
-'
-' Comparing the resolved code group with the initial code group.
-' The two code groups are not equal.
-'
-' * System.Security.Policy.FirstMatchCodeGroup summary *
-' A FirstMatchCodeGroup named with first-match merge logic has been created
-' with hash code 113155593. This code group contains a Zone - Intranet
-' membership condition with the permission set. The code group contains the
-' following policy: None. It also contains the following attributes:
-' There are 1 child elements in the code group.
-' Removing the Read-only code group.
-'
-' This sample completed successfully; press Exit to continue.
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb
deleted file mode 100644
index 34dff39aa39..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Policy.Gac/VB/gac.vb
+++ /dev/null
@@ -1,39 +0,0 @@
-'
-Imports System.Security.Policy
-Imports System.Security
-Imports System.Security.Permissions
-
-Class GacDemo
- _
- Overloads Shared Sub Main(ByVal args() As String)
- '
- Dim myGacInstalled As New GacInstalled
- '
-
- '
- Dim hostEvidence() As Object = {myGacInstalled}
- Dim assemblyEvidence() As Object
- Dim myEvidence As New Evidence(hostEvidence, assemblyEvidence)
- Dim myPerm As GacIdentityPermission = _
- CType(myGacInstalled.CreateIdentityPermission(myEvidence), _
- GacIdentityPermission)
- Console.WriteLine(myPerm.ToXml().ToString())
- '
-
- '
- Dim myGacInstalledCopy As GacInstalled = _
- CType(myGacInstalled.Copy(), GacInstalled)
- Dim result As Boolean = myGacInstalled.Equals(myGacInstalledCopy)
- '
-
- '
- Console.WriteLine( _
- ("Hashcode = " & myGacInstalled.GetHashCode().ToString()))
- '
-
- '
- Console.WriteLine(myGacInstalled.ToString())
- End Sub
- '
-End Class
-'
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecurityContext.Run/VB/form1.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecurityContext.Run/VB/form1.vb
deleted file mode 100644
index a6d88c224fa..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecurityContext.Run/VB/form1.vb
+++ /dev/null
@@ -1,19 +0,0 @@
- '
-Imports System.Security
-Imports System.Threading
-
-
-
-Class Test
-
- Shared Sub Main()
- Dim cCallBack As New ContextCallback(AddressOf Callback)
- SecurityContext.Run(SecurityContext.Capture(), cCallBack, "Hello world.")
- End Sub
-
- Shared Sub Callback(ByVal o As Object)
- Console.WriteLine(o)
-
- End Sub
-End Class
-'
\ No newline at end of file
diff --git a/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb b/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb
deleted file mode 100644
index 29cbe68b816..00000000000
--- a/snippets/visualbasic/VS_Snippets_CLR_System/system.security.permissions.principalpermission/vb/remarks.vb
+++ /dev/null
@@ -1,31 +0,0 @@
-Imports System.Security
-Imports System.Security.Policy
-Imports System.Security.Permissions
-
-Public Class PrincipalPermTest
- Public Shared Sub Main()
- Dummy1()
- End Sub
-
- Private Shared Sub Dummy1()
- '
- Dim ppBob As New PrincipalPermission("Bob", "Administrator")
- Dim ppLouise As New PrincipalPermission("Louise", "Administrator")
- Dim pp1 As IPermission = ppBob.Intersect(ppLouise)
- '
- End Sub
-
- Private Shared Sub Dummy2()
- '
- Dim pp1 As IPermission = New PrincipalPermission("", "Administrator")
- '
- End Sub
-
- Private Shared Sub Dummy3()
- '
- Dim ppBob As New PrincipalPermission("Bob", "Administrator")
- Dim ppLouise As New PrincipalPermission("Louise", "Administrator")
- '
- End Sub
-End Class
-
From 55e79e1666b89971f8f82202ec1408c8564e780b Mon Sep 17 00:00:00 2001
From: Genevieve Warren <24882762+gewarren@users.noreply.github.com>
Date: Fri, 20 Jun 2025 19:23:01 +0200
Subject: [PATCH 3/3] delete more referenced snippet files
---
.../Permission/cpp/Permission.cpp | 279 ------------------
.../CPP/resourcepermissionbase.cpp | 149 ----------
.../CPP/source.cpp | 23 --
.../CPP/source.cpp | 25 --
.../CPP/source.cpp | 17 --
.../CPP/source.cpp | 30 --
.../CPP/source.cpp | 35 ---
.../cpp/remarks.cpp | 39 ---
8 files changed, 597 deletions(-)
delete mode 100644 snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/CPP/source.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/CPP/source.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp
delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp
diff --git a/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp b/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp
deleted file mode 100644
index e61059912b5..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-// Types:System.Security.IPermission Vendor:Richter
-// Types:System.Security.ISecurityEncodable Vendor:Richter
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Reflection;
-
-// Enumerated type for permission states.
-[Serializable]
-public enum class SoundPermissionState
-{
- NoSound = 0,
- PlaySystemSounds = 1,
- PlayAnySound = 2
-};
-
-// Derive from CodeAccessPermission to gain implementations of the following
-// sealed IStackWalk methods: Assert, Demand, Deny, and PermitOnly.
-// Implement the following abstract IPermission methods:
-// Copy, Intersect, and IsSubSetOf.
-// Implementing the Union method of the IPermission class is optional.
-// Implement the following abstract ISecurityEncodable methods:
-// FromXml and ToXml.
-// Making the class 'sealed' is optional.
-
-public ref class SoundPermission sealed : public CodeAccessPermission,
- public IPermission, public IUnrestrictedPermission,
- public ISecurityEncodable, public ICloneable
-{
-private:
- bool specifiedAsUnrestricted;
-private:
- SoundPermissionState stateFlags;
-
- // This constructor creates and initializes
- // a permission with generic access.
-public:
- SoundPermission(PermissionState^ state)
- {
- specifiedAsUnrestricted = (state == PermissionState::Unrestricted);
- }
-
- // This constructor creates and initializes
- // a permission with specific access.
-public:
- SoundPermission(SoundPermissionState flags)
- {
- if (flags < SoundPermissionState::NoSound ||
- flags > SoundPermissionState::PlayAnySound)
- {
- throw gcnew ArgumentException("The value of \"flags\" is not" +
- " valid for the SoundPermissionState enumerated type");
- }
- stateFlags = flags;
- }
-
- // For debugging, return the state of this object as XML.
-public:
- virtual String^ ToString() override
- {
- return ToXml()->ToString();
- }
-
- // Private method to cast (if possible) an IPermission to the type.
-private:
- SoundPermission^ VerifyTypeMatch(IPermission^ target)
- {
- if (GetType() != target->GetType())
- {
- throw gcnew ArgumentException(String::Format(
- "The variable \"target\" must be of the {0} type",
- GetType()->FullName));
- }
- return (SoundPermission^) target;
- }
-
- // This is the Private Clone helper method.
-private:
- SoundPermission^ Clone(bool specifiedAsUnrestricted,
- SoundPermissionState flags)
- {
- SoundPermission^ soundPerm = (SoundPermission^) Clone();
- soundPerm->specifiedAsUnrestricted = specifiedAsUnrestricted;
- soundPerm->stateFlags = specifiedAsUnrestricted ?
- SoundPermissionState::PlayAnySound : flags;
- return soundPerm;
- }
-
- #pragma region IPermission^ Members
- //
- // Return a new object that contains the intersection
- // of 'this' and 'target'.
-public:
- virtual IPermission^ Intersect(IPermission^ target) override
- {
- // If 'target' is null, return null.
- if (target == nullptr)
- {
- return nullptr;
- }
-
- // Both objects must be the same type.
- SoundPermission^ soundPerm = VerifyTypeMatch(target);
-
- // If 'this' and 'target' are unrestricted,
- // return a new unrestricted permission.
- if (specifiedAsUnrestricted && soundPerm->specifiedAsUnrestricted)
- {
- return Clone(true, SoundPermissionState::PlayAnySound);
- }
-
- // Calculate the intersected permissions.
- // If there are none, return null.
- SoundPermissionState minimumPermission = (SoundPermissionState)
- Math::Min((int) stateFlags, (int) soundPerm->stateFlags);
- if ((int)minimumPermission == 0)
- {
- return nullptr;
- }
-
- // Return a new object with the intersected permission value.
- return Clone(false, minimumPermission);
- }
- //
-
- //
- // Called by the Demand method: returns true
- // if 'this' is a subset of 'target'.
-public:
- virtual bool IsSubsetOf(IPermission^ target) override
- {
- // If 'target' is null and this permission allows nothing,
- // return true.
- if (target == nullptr)
- {
- return (int)stateFlags == 0;
- }
-
- // Both objects must be the same type.
- SoundPermission^ soundPerm = VerifyTypeMatch(target);
-
- // Return true if the permissions of 'this'
- // is a subset of 'target'.
- return stateFlags <= soundPerm->stateFlags;
- }
- //
-
- //
- // Return a new object that matches 'this' object's permissions.
-public:
- virtual IPermission^ Copy () override sealed
- {
- return (IPermission^) Clone();
- }
- //
-
- //
- // Return a new object that contains the union of 'this' and 'target'.
- // Note: You do not have to implement this method.
- // If you do not, the version
- // in CodeAccessPermission does this:
- // 1. If target is not null, a NotSupportedException is thrown.
- // 2. If target is null, then Copy is called and
- // the new object is returned.
-public:
- virtual IPermission^ Union(IPermission^ target) override
- {
- // If 'target' is null, then return a copy of 'this'.
- if (target == nullptr)
- {
- return Copy();
- }
-
- // Both objects must be the same type.
- SoundPermission^ soundPerm = VerifyTypeMatch(target);
-
- // If 'this' or 'target' are unrestricted,
- // return a new unrestricted permission.
- if (specifiedAsUnrestricted || soundPerm->specifiedAsUnrestricted)
- {
- return Clone(true, SoundPermissionState::PlayAnySound);
- }
-
- // Return a new object with the calculated, unioned permission value.
- return Clone(false, (SoundPermissionState)
- Math::Max((int) stateFlags, (int) soundPerm->stateFlags));
- }
- //
- #pragma endregion
-
- #pragma region ISecurityEncodable^ Members
- //
- // Populate the permission's fields from XML.
-public:
- virtual void FromXml(SecurityElement^ element) override
- {
- specifiedAsUnrestricted = false;
- stateFlags = (SoundPermissionState)0;
-
- // If XML indicates an unrestricted permission,
- // make this permission unrestricted.
- String^ attributeString =
- (String^) element->Attributes["Unrestricted"];
- if (attributeString != nullptr)
- {
- specifiedAsUnrestricted = Convert::ToBoolean(attributeString);
- if (specifiedAsUnrestricted)
- {
- stateFlags = SoundPermissionState::PlayAnySound;
- }
- }
-
- // If XML indicates a restricted permission, parse the flags.
- if (!specifiedAsUnrestricted)
- {
- attributeString = (String^) element->Attributes["Flags"];
- if (attributeString != nullptr)
- {
- stateFlags = (SoundPermissionState) Convert::ToInt32(
- Enum::Parse(SoundPermissionState::typeid,
- attributeString, true));
- }
- }
- }
- //
-
- //
- // Produce XML from the permission's fields.
-public:
- virtual SecurityElement^ ToXml() override
- {
- // These first three lines create an element with the required format.
- SecurityElement^ element = gcnew SecurityElement("IPermission");
- // Replace the double quotation marks ()
- // with single quotation marks ()
- // to remain XML compliant when the culture is not neutral.
- element->AddAttribute("class",
- GetType()->AssemblyQualifiedName->Replace('\"', '\''));
- element->AddAttribute("version", "1");
-
- if (!specifiedAsUnrestricted)
- {
- element->AddAttribute("Flags",
- Enum::Format(SoundPermissionState::typeid, stateFlags, "G"));
- }
- else
- {
- element->AddAttribute("Unrestricted", "true");
- }
- return element;
- }
- //
- #pragma endregion
-
- #pragma region IUnrestrictedPermission^ Members
- //
- // Returns true if permission is effectively unrestricted.
-public:
- virtual bool IsUnrestricted()
- {
- // This means that the object is unrestricted at runtime.
- return stateFlags == SoundPermissionState::PlayAnySound;
- }
- //
- #pragma endregion
-
- #pragma region ICloneable^ Members
-
- // Return a copy of the permission.
-public:
- virtual Object^ Clone()
- {
- return MemberwiseClone();
- }
-
- #pragma endregion
-};
-//
diff --git a/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp b/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp
deleted file mode 100644
index a3567246321..00000000000
--- a/snippets/cpp/VS_Snippets_CLR/ResourcePermissionBase/CPP/resourcepermissionbase.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-//
-#using
-
-using namespace System;
-using namespace System::Security::Permissions;
-using namespace System::Collections;
-
-[Flags]
-
-public enum class MailslotPermissionAccess
-{
- None = 0,
- Send = 1 << 1,
- Receive = 1 << 2 | MailslotPermissionAccess::Send
-};
-
-
-[Serializable]
-public ref class MailslotPermissionEntry
-{
-private:
- String^ name;
- String^ machineName;
- MailslotPermissionAccess permissionAccess;
-
-internal:
- MailslotPermissionEntry( ResourcePermissionBaseEntry^ baseEntry )
- {
- this->permissionAccess = (MailslotPermissionAccess)baseEntry->PermissionAccess;
- this->name = baseEntry->PermissionAccessPath[ 0 ]->ToString();
- this->machineName = baseEntry->PermissionAccessPath[ 1 ]->ToString();
- }
-
- ResourcePermissionBaseEntry^ GetBaseEntry()
- {
- array^newStrings = {this->Name,this->MachineName};
- ResourcePermissionBaseEntry^ baseEntry = gcnew ResourcePermissionBaseEntry( (int)(this->PermissionAccess),newStrings );
- return baseEntry;
- }
-
-public:
- MailslotPermissionEntry( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
- {
- this->permissionAccess = permissionAccess;
- this->name = name;
- this->machineName = machineName;
- }
-
- property String^ Name
- {
- String^ get()
- {
- return this->name;
- }
- }
-
- property String^ MachineName
- {
- String^ get()
- {
- return this->machineName;
- }
- }
-
- property MailslotPermissionAccess PermissionAccess
- {
- MailslotPermissionAccess get()
- {
- return this->permissionAccess;
- }
- }
-};
-
-
-[Serializable]
-public ref class MailslotPermission: public ResourcePermissionBase
-{
-private:
- ArrayList^ innerCollection;
- void SetNames()
- {
- this->PermissionAccessType = MailslotPermissionAccess::typeid;
- array^newStrings = {"Name","Machine"};
- this->TagNames = newStrings;
- }
-
-
-internal:
- void AddPermissionAccess( MailslotPermissionEntry^ entry )
- {
- ResourcePermissionBase::AddPermissionAccess( entry->GetBaseEntry() );
- }
-
- void Clear()
- {
- ResourcePermissionBase::Clear();
- }
-
- void RemovePermissionAccess( MailslotPermissionEntry^ entry )
- {
- ResourcePermissionBase::RemovePermissionAccess( entry->GetBaseEntry() );
- }
-
-
-public:
- MailslotPermission()
- {
- SetNames();
- }
-
- MailslotPermission( PermissionState state )
- : ResourcePermissionBase( state )
- {
- SetNames();
- }
-
- //
- MailslotPermission( MailslotPermissionAccess permissionAccess, String^ name, String^ machineName )
- {
- SetNames();
- this->AddPermissionAccess( gcnew MailslotPermissionEntry( permissionAccess,name,machineName ) );
- }
-
- MailslotPermission( array^permissionAccessEntries )
- {
- SetNames();
- if ( permissionAccessEntries == nullptr )
- throw gcnew ArgumentNullException( "permissionAccessEntries" );
-
- for ( int index = 0; index < permissionAccessEntries->Length; ++index )
- this->AddPermissionAccess( permissionAccessEntries[ index ] );
- }
- //
-
- property ArrayList^ PermissionEntries
- {
- ArrayList^ get()
- {
- if ( this->innerCollection == nullptr )
- this->innerCollection = gcnew ArrayList;
-
- this->innerCollection->InsertRange( 0, safe_cast(ResourcePermissionBase::GetPermissionEntries()) );
- return this->innerCollection;
- }
- }
-};
-//
-
-void main(){}
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/CPP/source.cpp
deleted file mode 100644
index f0687bcf481..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileDialogPermissionAttribute Example/CPP/source.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-using namespace System;
-using namespace System::Security::Permissions;
-
-//
- [assembly:FileDialogPermissionAttribute(SecurityAction::RequestMinimum,Unrestricted=true)];
- //In C++, you must specify that you are using the assembly scope when making a request.
-//
-
-namespace Snippet2
-{
-//
- [FileDialogPermissionAttribute(SecurityAction::Demand,Unrestricted=true)]
-//
- public ref class SampleClass{};
-}
-
-namespace Snippet3
-{
-//
- //[FileDialogPermissionAttribute(SecurityAction::Assert,Unrestricted=true)]
-//
- public ref class SampleClass{};
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp
deleted file mode 100644
index 6279477dcee..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic FileIOPermissionAttribute Example/CPP/source.cpp
+++ /dev/null
@@ -1,25 +0,0 @@
-using namespace System;
-using namespace System::Security::Permissions;
-
-namespace Snippet1
-{
-//
-[FileIOPermissionAttribute(SecurityAction::PermitOnly,ViewAndModify="C:\\example\\sample.txt")]
-//
- public ref class SampleClass{};
-}
-namespace Snippet2
-{
-//
- [FileIOPermissionAttribute(SecurityAction::Demand,Unrestricted=true)]
-//
- public ref class SampleClass{};
-}
-
-namespace Snippet3
-{
-//
- //[FileIOPermissionAttribute(SecurityAction::Assert,Unrestricted=true)]
-//
- public ref class SampleClass{};
-}
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp
deleted file mode 100644
index da729d96fce..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission Example/CPP/source.cpp
+++ /dev/null
@@ -1,17 +0,0 @@
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Policy;
-using namespace System::Security::Principal;
-
-int main(array ^args)
-{
- System::String^ null;
- AppDomain::CurrentDomain->SetPrincipalPolicy(PrincipalPolicy::WindowsPrincipal);
- PrincipalPermission^ principalPerm = gcnew PrincipalPermission(null, "Administrators" );
- principalPerm->Demand();
- Console::WriteLine("Demand succeeded");
- return 0;
-}
-//
\ No newline at end of file
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/CPP/source.cpp
deleted file mode 100644
index 0bde5631510..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermission.IsSubsetOf Example/CPP/source.cpp
+++ /dev/null
@@ -1,30 +0,0 @@
-#using
-#using
-#using
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Policy;
-using namespace System::Windows::Forms;
-
-public ref class Form1: public Form
-{
-protected:
- TextBox^ textBox1;
-
-public:
- void Method()
- {
- //
- //Define users and roles.
- PrincipalPermission^ ppBob = gcnew PrincipalPermission( "Bob", "Manager" );
- PrincipalPermission^ ppLouise = gcnew PrincipalPermission( "Louise", "Supervisor" );
- PrincipalPermission^ ppGreg = gcnew PrincipalPermission( "Greg", "Employee" );
-
- //Define groups of users.
- PrincipalPermission^ pp1 = (PrincipalPermission^) (ppBob->Union( ppLouise ));
- PrincipalPermission^ pp2 = (PrincipalPermission^) (ppGreg->Union( pp1 ));
- //
- }
-};
diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp
deleted file mode 100644
index cbff0e29e8a..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_Classic/classic PrincipalPermissionAttribute Example/CPP/source.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Policy;
-using namespace System::Security::Principal;
-
-[PrincipalPermission(SecurityAction::Demand, Role = "Administrators")]
-void CheckAdministrator()
-{
- Console::WriteLine("User is an administrator.");
-}
-int main(array ^args)
-{
- try
- {
- // Must set PrincipalPolicy to WindowsPrincipal
- AppDomain::CurrentDomain->SetPrincipalPolicy(PrincipalPolicy::WindowsPrincipal);
- // Check using declarative security.
- CheckAdministrator();
- // Check using Imperative security.
- System::String^ null;
- PrincipalPermission^ principalPerm = gcnew PrincipalPermission(null, "Administrators" );
- principalPerm->Demand();
- Console::WriteLine("Demand succeeded");
- }
- catch (Exception ^e)
- {
- Console::WriteLine(e->Message);
- }
- return 0;
-}
-
-
-//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp
deleted file mode 100644
index bb909af8192..00000000000
--- a/snippets/cpp/VS_Snippets_CLR_System/system.security.permissions.principalpermission/cpp/remarks.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-
-using namespace System;
-using namespace System::Security;
-using namespace System::Security::Permissions;
-using namespace System::Security::Policy;
-
-public ref class PrincipalPermTest
-{
-public:
- void Dummy1()
- {
- //
- PrincipalPermission^ ppBob = gcnew PrincipalPermission("Bob", "Administrator");
- PrincipalPermission^ ppLouise = gcnew PrincipalPermission("Louise", "Administrator");
- IPermission^ pp1 = ppBob->Intersect(ppLouise);
- //
- }
-
- void Dummy2()
- {
- //
- IPermission^ pp1 = gcnew PrincipalPermission("", "Administrator");
- //
- }
-
- void Dummy3()
- {
- //
- PrincipalPermission^ ppBob = gcnew PrincipalPermission("Bob", "Administrator");
- PrincipalPermission^ ppLouise = gcnew PrincipalPermission("Louise", "Administrator");
- //
- }
-};
-
-
-int main()
-{
-
-}