C#MS Office Interop应用Azure信息保护(AIP)
我需要创建PowerPoints,但是当我保存文件(Saveas方法)时,有Azure分类加载项,需要手动单击(公共/内部/机密)才能完成保存PPT文件。
using Microsoft.Office.Interop.PowerPoint;
var pptApplication = new Application();
var pptPresentation = pptApplication.Presentations.Add();
pptPresentation.SaveAs(@"C:\temp\test.pptx", PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
pptPresentation.Close();
pptApplication.Quit();
我找到了应用标签的在线PowerShell方法,但是即使有效,它也可以在已经存在的(已保存)文件上完成。
然后另一个发现是 https://stackoverflow.com/a/a/57413086/11305428 ,但我不知道该如何弄清楚如何弄清楚如何弄清楚如何弄清楚如何应用标签msip_label__enabled = true
我有我的org中使用的标签的指南
strmsipclassConfInditial =“ msip_label_-guid-_enabled = true;
但是还没有找到如何将其应用于提供的Interop的元数据。有人知道吗?
使用PowerPoint Interop,因为我没有找到任何免费库。
I need to create PowerPoints but when I’m saving the file (SaveAs method), there is Azure classification add-in which requires manual click (public/internal/confidential) to finish saving the ppt file.
using Microsoft.Office.Interop.PowerPoint;
var pptApplication = new Application();
var pptPresentation = pptApplication.Presentations.Add();
pptPresentation.SaveAs(@"C:\temp\test.pptx", PpSaveAsFileType.ppSaveAsDefault, MsoTriState.msoTrue);
pptPresentation.Close();
pptApplication.Quit();
I found online PowerShell method of applying labels but even if it works, it’s done on already existing(saved) file.
Then another find is https://stackoverflow.com/a/57413086/11305428 but I can’t figure out how to apply the label MSIP_Label__Enabled=True
I have the GUID of tags used in my org
strMSIPClassConfidential = "MSIP_Label_-GUID-_Enabled=true;
but haven‘t found how I would apply it to metadata with provided interop. Anyone knows?
Using PowerPoint interop because I haven't found any free libraries for this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有关找到此条目的人的更多信息:
当您选择适当的款项时,使用AIP手动保存时,有许多自定义属性添加到Office文件中。
它们以“ MSIP_LABEL__”格式命名(自定义属性),并具有关联的属性值。
要确定可用的标签(即:为您的组织配置),您可以在线查找有关PowerShell命令的各种信息,以询问和列出它们。
但是,如果您仅对一些标签选项感兴趣(例如机密,非官方,官方),则可以首先创建手动不同的示例办公文件,并使用不同的灵敏度标签保存。
然后依次打开每个单词,例如api_blankdocument_cofidentialmedialaiplable.docx(注意:旧格式。信息,然后单击属性v 标题,然后从弹出的唯一选项中选择高级属性。
将打开一个对话框,现在单击“自定义”选项卡,您将看到(部分可见)各种MSIP_LABEL _ ???保存文档时,该词适用。
您可以通过依次单击每个自定义属性并从“名称”和“ value”字段复制/粘贴来提取属性名称和值。请注意,所有值都是类型的“文本”(尽管一个是ISO日期和一个数值)。
您可以使用Office对象(docObj,pptobj,xlsobj)customProperties属性及其.ADD方法来创建您需要的标签(** **此逻辑假设该对象尚未拥有这些属性**)。
在VBA中,这是我创建的例程,它通过DocObj也添加了所需的属性:
这些标签上的信息(其中一些可能会在以后的AIP版本中取代):
https://learn.microsoft.com/en-us/en-us/in-us/information-protection/information-protection/developpection/develops/concept--concept--conplove-concept--concept--concept--concept--concept--concept--concept--concept--concept--concepp--- mip-metadata
Further Information for those finding this entry:
There are number of Custom Properties added to Office files when saving manually with AIP enabled when you choose the appropriate Lable.
They are named (the Custom Property) in the format "MSIP_Label__" with an associated value for the Property.
To work out which Labels are available (ie: configured for your Organisation) you can find information online on various on PowerShell commands to interrogate and list them.
However if you are just interested in only a few label options (e.g Confidential, Unofficial, Official) for your programming task then you can first create manually different sample office files and save them with different Sensitivity Labels.
Then open each one in turn in e.g a Word API_BlankDocument_CofidentialMedialAIPLable.docx (note: older format .doc doesn't work I beleive) and click File --> Info, Then click on the Properties v Header, and choose Advanced Properties from the only option that pops up.
An Dialog will open, now click on the "Custom" Tab, and you will see (partially visible) the various MSIP_Label_??? that Word applies when saving the document.
You can then extract then Properties Name and Value by clicking on each Custom Property in turn and copy/pasting from "Name" and "Value" fields. Note that all values are of Type "Text" (despite one being an ISO Dates and one Numerical).
You can the use the Office object (docobj, pptobj, xlsobj) CustomProperties property and its .Add method to create the labels you need on the fly (** this logic assumes the object does not already have those properties already **).
In VBA this is the routine I created which is passed a docobj too have the required Properties added:
Information on these labels (some of which may be superseeded in future AIP versions) I found here:
https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata
使它起作用。如果有人要评论该代码确实可以随意编辑的内容。
Got it working. If anyone is up to commenting of what the code does feel free to edit.