user124114
user124114

Reputation: 8692

How to use Microsoft MIP SDK from Python?

I'm building an app that automatically labels Office files on Windows computers. To apply my sensitivity labels to documents programmatically, Microsoft tells me to use its MIP SDK.

But the SDK is in C++, with some convoluted async Observer patterns, so it's not clear to me how to call its functions from Python.

Has anyone succeeded in using the MIP SDK with Python 3? Can you share a concrete Python example of calling the SetLabel() function on a file?

Upvotes: 6

Views: 2329

Answers (1)

Life is complex
Life is complex

Reputation: 15629

I have spent sometime looking into this problem. Microsoft doesn't make it clear on how to call their MIP C++ code using Python. It's also unclear for me if you're trying to set sensitivity labels on local Office files or ones stored in SharePoint or in Office 365.

I previously mentioned using Python Bindings, but after doing some research there are other ways.

Technique One


Microsoft has a PowerShell framework called Security & Compliance Center PowerShell. One the cmdlet is Set-Label, which can be used to enable sensitivity labels for Office files. There is another module called Set-LabelPolicy that can assist in setting global sensitivity policies.

PowerShell cmdlet can be called from Python. There are lots of examples on Stack Overflow on how to accomplish this.

Technique Two


Again Microsoft really requires you to dig for information to use Python over their prefer coding languages.

Microsoft has a GitHub project called AutoRest Python. This project generates Python code that is needed to interact with Microsoft Information Protection (MIP) and other Microsoft centric products.

The other GitHub project that is needed is msrest for python.

If you dig through some of Microsoft GitHub repositories you will find examples on how to use these modules.

Technique Three


You can also use Python to set registry settings related to sensitivity labels for Office files. If needed I can provide you the registry keys.

Upvotes: 2

Related Questions