SecureEnvironment.IsUserActivated(ContentUser) 方法

定義

表示是否已啟用指定使用者存取權限管理內容。

C#
public static bool IsUserActivated (System.Security.RightsManagement.ContentUser user);

參數

user
ContentUser

要授與版權管理內容存取權的使用者或使用者群組。

傳回

如果已啟用指定的 user 來存取版權管理內容,則為 true;否則為 false

範例

下列範例示範如何使用 IsUserActivated 方法來判斷指定的使用者是否已獲授權存取許可權受管理的內容。

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);
    }
}

適用於

產品 版本
.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