共用方式為


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

適用於