RightsManagementInformation.LoadUseLicense(ContentUser) 메서드

정의

암호화된 권한 관리 데이터 스트림에서 지정된 사용자의 포함된 UseLicense를 반환합니다.

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

매개 변수

userKey
ContentUser

UseLicense를 반환할 사용자 또는 사용자 그룹입니다.

반환

지정된 사용자의 UseLicense입니다. 지정된 userKey에 일치하는 UseLicense가 패키지에 포함되어 있지 않으면 null을 반환합니다.

예외

userKey 매개 변수가 null인 경우

이 클래스의 현재 버전으로는 이 패키지에 있는 권한 관리 정보를 읽을 수 없는 경우

예제

다음 예제에서는 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.")

적용 대상

추가 정보