Compartir a través de


Download.GetDRMHeader

banner art

Previous Next

Download.GetDRMHeader

The GetDRMHeader method retrieves the existing content header from a packaged file so you can modify it. This method is optional.

Syntax

  bstrContentHeader = Download
  .GetDRMHeader(
  bstrPathFileName
  )

Parameters

bstrPathFileName

[in] String containing the path and file name of the packaged file.

Return Values

This method returns a String containing the content header from the packaged file. If it fails, it returns a number in the error object.

Remarks

Use this method if you need to modify the original content header rather than replace it (for example, to add an attribute). However, if you simply want to replace the content header, you do not need to retrieve the original one first.

Example Code

<%option explicit%>
<%Response.Buffer = True%>
<%
    ' Declare objects and variables.
    Dim strPath, strContent, strUserName, publickey, privatekey
    Dim objDownloadMgr, objHeader, strHeader

    ' Retrieve end user and file information from the form.
    strPath = Request.QueryString("path")
    strContent = Request.QueryString("content")
    strUserName= Request.QueryString("username")
 
    ' Create a download manager object.
    Set objDownloadMgr = Server.CreateObject("wmrmobjs.reheader") 

    ' Create a header object.
    Set objHeader = Server.CreateObject("Wmrmobjs.WMRMHeader")

    ' Get the original content header from the packaged file.
    strHeader = objDownloadMgr.GetDRMHeader(strPath+"\"+strContent)

    ' Place header information into the header object.
    objHeader.Header = strHeader
    objHeader.Attribute("UserName") = strUserName
    privatekey = "XXX"    ' XXX is the packaging server's private key.
    objHeader.Sign(privatekey)
    strHeader = objHeader.Header

    ' Add the header to the Response object.
    Response.AddHeader "Content-Disposition", _
                       "attachment;filename="+strContent

    ' Force the end user to download the packaged file.
    objDownloadMgr.ForceCompleteDownload = True

    ' Download the file.
    call objDownloadMgr.DownLoad(strPath+"\"+strContent, strHeader)
%>

Requirements

Version: Windows Media Rights Manager 7 SDK or later

Reference: DRMReheader 1.0 Type Library

Library: wmrmrehd.dll

Platform: Windows Server 2003

See Also

Previous Next

© 2007 Microsoft Corporation. All rights reserved.