RightsManagementInformation.LoadUseLicense(ContentUser) Método

Definição

Retorna o UseLicense inserido de um usuário especificado do fluxo de dados criptografados de gerenciamento de direitos.

public:
 System::Security::RightsManagement::UseLicense ^ LoadUseLicense(System::Security::RightsManagement::ContentUser ^ userKey);
public System.Security.RightsManagement.UseLicense LoadUseLicense (System.Security.RightsManagement.ContentUser userKey);
member this.LoadUseLicense : System.Security.RightsManagement.ContentUser -> System.Security.RightsManagement.UseLicense
Public Function LoadUseLicense (userKey As ContentUser) As UseLicense

Parâmetros

userKey
ContentUser

O usuário ou grupo de usuários para o qual retornar o UseLicense.

Retornos

O UseLicense para o usuário especificado ou então null se o pacote não contém um UseLicense correspondente ao userKey fornecido.

Exceções

O parâmetro userKey é null.

As informações de gerenciamento de direitos neste pacote não podem ser lidas pela versão atual dessa classe.

Exemplos

O exemplo a seguir mostra como usar o método LoadUseLicense.

ShowStatus("   Opening the encrypted Package.");
EncryptedPackageEnvelope ePackage =
    EncryptedPackageEnvelope.Open(xpsFile, FileAccess.ReadWrite);
RightsManagementInformation rmi =
    ePackage.RightsManagementInformation;

ShowStatus("   Looking for an embedded UseLicense for user:\n       " +
           currentUserId + " [" + _authentication + "]");
UseLicense useLicense =
    rmi.LoadUseLicense(
        new ContentUser(currentUserId, _authentication));

ReadOnlyCollection<ContentGrant> grants;
if (useLicense == null)
{
    ShowStatus("   No Embedded UseLicense found.\n       " +
               "Attempting to acqure UseLicnese\n       " +
               "from the PublishLicense.");
    PublishLicense pubLicense = rmi.LoadPublishLicense();

    ShowStatus("   Referral information:");

    if (pubLicense.ReferralInfoName == null)
        ShowStatus("       Name: (null)");
    else
        ShowStatus("       Name: " + pubLicense.ReferralInfoName);

    if (pubLicense.ReferralInfoUri == null)
        ShowStatus("    Uri: (null)");
    else
        ShowStatus("    Uri: " +
            pubLicense.ReferralInfoUri.ToString());

    useLicense = pubLicense.AcquireUseLicense(_secureEnv);
    if (useLicense == null)
    {
        ShowStatus("   User DOES NOT HAVE RIGHTS\n       " +
            "to access this document!");
        return false;
    }
}// end:if (useLicense == null)
ShowStatus("   UseLicense acquired.");
ShowStatus("   Opening the encrypted Package.")
Dim ePackage As EncryptedPackageEnvelope = EncryptedPackageEnvelope.Open(xpsFile, FileAccess.ReadWrite)
Dim rmi As RightsManagementInformation = ePackage.RightsManagementInformation

ShowStatus("   Looking for an embedded UseLicense for user:" & vbLf & "       " & currentUserId & " [" & _authentication & "]")
Dim useLicense As UseLicense = rmi.LoadUseLicense(New ContentUser(currentUserId, _authentication))

Dim grants As ReadOnlyCollection(Of ContentGrant)
If useLicense Is Nothing Then
    ShowStatus("   No Embedded UseLicense found." & vbLf & "       " & "Attempting to acqure UseLicnese" & vbLf & "       " & "from the PublishLicense.")
    Dim pubLicense As PublishLicense = rmi.LoadPublishLicense()

    ShowStatus("   Referral information:")

    If pubLicense.ReferralInfoName Is Nothing Then
        ShowStatus("       Name: (null)")
    Else
        ShowStatus("       Name: " & pubLicense.ReferralInfoName)
    End If

    If pubLicense.ReferralInfoUri Is Nothing Then
        ShowStatus("    Uri: (null)")
    Else
        ShowStatus("    Uri: " & pubLicense.ReferralInfoUri.ToString())
    End If

    useLicense = pubLicense.AcquireUseLicense(_secureEnv)
    If useLicense Is Nothing Then
        ShowStatus("   User DOES NOT HAVE RIGHTS" & vbLf & "       " & "to access this document!")
        Return False
    End If
End If ' end:if (useLicense == null)
ShowStatus("   UseLicense acquired.")

Aplica-se a

Confira também