问题描述
基本上,我们的要求是下载现有pdf文档(具有MIP加密),然后解密PDF文件,修改PDF中的内容,然后再加密。我正在使用File SDK。直到修改我能够执行的内容,现在我想重新加密文件。设置标签(从protection.office.com启用加密)时,出现错误“ TemplateNotFoundException:无法识别的模板ID。” 。 请提出建议。
var result = Task.Run(async () => await handler.CommitAsync(options.OutputName)).Result;
解决方法
似乎与标签关联的RMS保护模板已被删除或设置为已存档。您可以删除并重新创建该标签,或者必须使用AIP服务cmdlet来调查您的模板之一是否已设置为存档或删除。
您可以使用Get-AIPServiceTemplate列出模板。模板的名称应与您的标签相符。
如果模板设置为已存档,请使用Set-AIPSerivceTemplate将状态设置回已发布。如果模板不存在,则可以删除标签并重新开始(尽管很奇怪,模板将被删除),也可以使用PowerShell更新保护设置。
This doc介绍了如何通过PowerShell管理标签。您将执行以下操作:
get-label | where {$_.displayname -eq "TOP SECRET"} | fl displayname,labelactions
哪个会输出:
DisplayName : TOP SECRET
LabelActions : {{"Type":"encrypt","SubType":null,"Settings":[{"Key":"disabled","Value":"false"},{"Key":"protectiontype","Value":"template"},{"Key":"templateid","Value":"0e7fea72-7bba-4438-a070-95c292cd6f8c"},{"Key":"templat
earchived","Value":"True"},{"Key":"linkedtemplateid",{"K
ey":"contentexpiredondateindaysornever","Value":"Never"},{"Key":"offlineaccessdays","Value":"-1"},{"Key"
:"rightsdefinitions","Value":"[{\"Identity\":\"miltor.onmicrosoft.com\",\"Rights\":\"VIEW,VIEWRIGHTSDATA,DOCEDIT,EDIT,PRINT,EXTRACT,REPLY,REPLYALL,FORWARD,OBJMODEL\"},{\"Identity\":\"microsoft.com\",\"Rights\
":\"VIEW,{\"Identity\":\"test@milt0r.com\",\"Rights\":\"PROJECT\"}]"}]},{"Ty
pe":"applycontentmarking","SubType":"header","Settings":[{"Key":"fontsize","Value":"10"},{"Key":"placeme
nt","Value":"Header"},{"Key":"text","Value":"Property of Contoso"},{"Key":"fontcolor","Value":"#000000"},{"Key":"margin","Value":"5"},{"Key":"alignment","Value":"Left"},{"Key":"disabled","Value":"false"}]},{
"Type":"applycontentmarking","SubType":"footer",{"Key":"plac
ement","Value":"Footer"},"Value":"#00000
0"},{"Type":"applywatermarking",{"Key":"layout","Value":"Diagonal"},{"Key":"te
xt","Value":"Property of Contoso"}]}}
在该JSON中,找到linkedtemplateid: {“ Key”:“ linkedtemplateid”,“ Value”:“ 0e7fea72-7bba-4438-a070-95c292cd6f8c”}
这是RMS中应该存在的模板ID,以为标签提供保护措施。如果不存在,请使用Add-AIPServiceTemplate创建新模板,并通过Set-Label更新标签,并提供 EncryptionProtectionType 和 EncryptionRightsDefinitions 。