SecureEnvironment 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
表示一个用于用户激活、许可证绑定和其他权限管理操作的安全客户端会话。
public ref class SecureEnvironment : IDisposable
C#
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class SecureEnvironment : IDisposable
C#
public class SecureEnvironment : IDisposable
[<System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)>]
type SecureEnvironment = class
interface IDisposable
type SecureEnvironment = class
interface IDisposable
Public Class SecureEnvironment
Implements IDisposable
- 继承
-
SecureEnvironment
- 属性
- 实现
以下示例演示如何使用 SecureEnvironment 类
C#
string applicationManifest = "<manifest></manifest>";
if (File.Exists("rpc.xml"))
{
StreamReader manifestReader = File.OpenText("rpc.xml");
applicationManifest = manifestReader.ReadToEnd();
}
if (_secureEnv == null)
{
if (SecureEnvironment.IsUserActivated(new ContentUser(
_currentUserId, AuthenticationType.Windows)))
{
_secureEnv = SecureEnvironment.Create(
applicationManifest, new ContentUser(
_currentUserId, AuthenticationType.Windows));
}
else
{
_secureEnv = SecureEnvironment.Create(
applicationManifest,
AuthenticationType.Windows,
UserActivationMode.Permanent);
}
}
Dim applicationManifest As String = "<manifest></manifest>"
If File.Exists("rpc.xml") Then
Dim manifestReader As StreamReader = File.OpenText("rpc.xml")
applicationManifest = manifestReader.ReadToEnd()
End If
If _secureEnv Is Nothing Then
If SecureEnvironment.IsUserActivated(New ContentUser(_currentUserId, AuthenticationType.Windows)) Then
_secureEnv = SecureEnvironment.Create(applicationManifest, New ContentUser(_currentUserId, AuthenticationType.Windows))
Else
_secureEnv = SecureEnvironment.Create(applicationManifest, AuthenticationType.Windows, UserActivationMode.Permanent)
End If
End If
与其他 System.Security.RightsManagement 类型一样, SecureEnvironment 仅在完全信任应用程序中可用。
Application |
获取创建 ApplicationManifest 时指定的 SecureEnvironment。 |
User |
获取创建 SecureEnvironment 时指定的用户或用户组。 |
Create(String, Authentication |
创建给定了应用程序权限清单 AuthenticationType 和 UserActivationMode 的安全客户端会话。 |
Create(String, Content |
使用给定权限清单为指定用户创建安全客户端会话。 |
Dispose() |
释放由 SecureEnvironment 使用的所有资源。 |
Dispose(Boolean) |
释放由 SecureEnvironment 占用的非托管资源,还可以另外再释放托管资源。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
返回激活用户的列表。 |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Is |
表示是否已激活访问权限管理内容的给定用户。 |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
Remove |
删除指定用户的许可证激活。 |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9 |