语言

SecureEnvironment 类

定义

表示用户激活、许可证绑定和其他权限管理操作的安全客户端会话。

public ref class SecureEnvironment : IDisposable
[System.Security.SecurityCritical(System.Security.SecurityCriticalScope.Everything)]
public class SecureEnvironment : IDisposable
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 的使用

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 只能在完全信任应用程序中使用。

属性

名称 说明
ApplicationManifest

ApplicationManifest获取创建时SecureEnvironment指定的值。

User

获取创建时 SecureEnvironment 指定的用户或用户组。

方法

名称 说明
Create(String, AuthenticationType, UserActivationMode)

创建一个安全客户端会话,给定应用程序权限清单, AuthenticationType以及 UserActivationMode。

Create(String, ContentUser)

为具有给定权限清单的指定用户创建安全客户端会话。

Dispose()

释放该 SecureEnvironment命令使用的所有资源。

Dispose(Boolean)

释放由托管资源使用 SecureEnvironment 的非托管资源,并选择性地释放托管资源。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetActivatedUsers()

返回已激活的用户的列表。

GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type。

(继承自 Object)
IsUserActivated(ContentUser)

指示是否已激活给定用户以访问权限托管内容。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
RemoveActivatedUser(ContentUser)

删除指定用户的许可证激活。

ToString()

返回一个表示当前对象的字符串。

(继承自 Object)

适用于