CryptoProvider.CanDecrypt 屬性

定義

取得值,指出使用者是否具有解密權限。

public bool CanDecrypt { get; }

屬性值

trueUseLicense如果 授與使用者解密的許可權,則為 , false 否則為 。

範例

下列範例示範如何使用 CanDecrypt 屬性來判斷是否允許解密。

ShowStatus("   Binding UseLicense with the SecureEnvironment" +
         "\n       to obtain the CryptoProvider.");
CryptoProvider cryptoProvider = useLicense.Bind(_secureEnv);

ShowStatus("   Obtaining BoundGrants.");
ReadOnlyCollection<ContentGrant> grants =
    cryptoProvider.BoundGrants;

rightsBlockTitle.Text = "Rights - " + Filename(useLicenseFile);
rightsBlock.Text = "GRANTS LIST\n-----------------\n";
foreach (ContentGrant grant in grants)
{
    rightsBlock.Text += "USER:  " + grant.User.Name + " [" +
        grant.User.AuthenticationType + "]\n";
    rightsBlock.Text += "RIGHT: " + grant.Right.ToString() + "\n";
    rightsBlock.Text += "    From:  " + grant.ValidFrom + "\n";
    rightsBlock.Text += "    Until: " + grant.ValidUntil + "\n";
}

if (cryptoProvider.CanDecrypt == true)
    ShowStatus("   Decryption granted.");
else
    ShowStatus("   CANNOT DECRYPT!");

備註

CanDecrypttrue如果系結至這個 CryptoProviderUseLicense 會授與使用者讀取存取許可權,例如檢視、編輯、列印或擁有者,則傳回 。

適用於

另請參閱