SecureEnvironment.IsUserActivated(ContentUser) 方法

定义

表示是否已激活访问权限管理内容的给定用户。

public:
 static bool IsUserActivated(System::Security::RightsManagement::ContentUser ^ user);
public static bool IsUserActivated (System.Security.RightsManagement.ContentUser user);
static member IsUserActivated : System.Security.RightsManagement.ContentUser -> bool
Public Shared Function IsUserActivated (user As ContentUser) As Boolean

参数

user
ContentUser

要为其授予权限管理内容访问权限的用户或用户组。

返回

如果已激活访问权限管理内容的给定 user,则为 true;否则为 false

示例

以下示例演示如何使用 IsUserActivated 方法确定给定用户是否已获得访问权限托管内容的访问权限。

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

适用于