CryptoProvider.CanDecrypt Property


Gets a value that indicates whether the user has rights to decrypt.

Namespace:   System.Security.RightsManagement
Assembly:  WindowsBase (in WindowsBase.dll)

public bool CanDecrypt { get; }

Property Value

Type: System.Boolean

true if the UseLicense grants the user rights to decrypt; otherwise, false.

CanDecrypt returns true if the UseLicense bound to this CryptoProvider grants the user read access rights such as View, Edit, Print, or Owner.

The following example shows how to use the CanDecrypt property to determine if decryption is allowed.

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

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

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.");
    ShowStatus("   CANNOT DECRYPT!");

.NET Framework
Available since 3.0
Return to top