简体   繁体   English

检测到该文件受 Microsoft Azure 信息保护保护

[英]Detect that file is protected by Microsoft Azure Information Protection

Currently, our app doesn't support files that are protected by Azure/Microsoft Information Protection ( https://learn.microsoft.com/en-us/azure/information-protection/what-is-information-protection ).目前,我们的应用程序不支持受 Azure/Microsoft 信息保护 ( https://learn.microsoft.com/en-us/azure/information-protection/what-is-information-protection ) 保护的文件。 I want to inform the user that our app doesn't support these files or give them a warning that functionalities are more limited.我想通知用户我们的应用程序不支持这些文件,或者警告他们功能更加有限。

I have found one way to peek if the file is protected here: https://learn.microsoft.com/en-us/information-protection/develop/quick-app-initialization-csharp我找到了一种查看文件是否受保护的方法: https ://learn.microsoft.com/en-us/information-protection/develop/quick-app-initialization-csharp

Although this could work, it is too much overhead to configure this approach.尽管这可行,但配置此方法的开销太大。

Is there a fast, simple clean way to know that a file is protected by Azure/Microsoft Information Protection?是否有一种快速、简单、干净的方法来了解文件是否受 Azure/Microsoft 信息保护保护?

For Word, Excel and PowerPoint documents, I could try to open these files as ZIP files (because Office document files are ZIP files) and look for an 'EncryptedPackage' file in the root folder.对于 Word、Excel 和 PowerPoint 文档,我可以尝试将这些文件作为 ZIP 文件打开(因为 Office 文档文件是 ZIP 文件)并在根文件夹中查找“EncryptedPackage”文件。 But maybe there is a more conventional way.但也许有更传统的方式。

For Word, Excel and PowerPoint documents we can zip and unzip files using System.IO.Compression对于 Word、Excel 和 PowerPoint 文档,我们可以使用System.IO.Compression压缩和解压缩文件

Zip file:压缩文件:

在此处输入图像描述

Unzip Files:解压缩文件:

在此处输入图像描述

Snippet for Encryption and Decryption of text文本加解密片段

在此处输入图像描述

            string Path = @"C:\Static\";
            string zipPath = @"C:\Temp\Zip\result.zip";

            //To Zip the files
            ZipFile.CreateFromDirectory(Path, zipPath);

            //to Unzip the files
            ZipFile.ExtractToDirectory(zipPath, @"C:\UnZipped\");

Encryption Code:加密代码:

           byte[] key_Array;
            byte[] Encrypt_Array = UTF8Encoding.UTF8.GetBytes(txtPlain.Text);

            string key = "Some Securty Key";
            if (true)
            {
                MD5CryptoServiceProvider hashingMd5 = new MD5CryptoServiceProvider();
                keyArray = hashingMd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
                hashingMd5.Clear();
            }
            TripleDESCryptoServiceProvider tdesSp = new TripleDESCryptoServiceProvider();
            tdesSp.Key = key_Array;
            tdesSp.Mode = CipherMode.ECB;
            tdesSp.Padding = PaddingMode.PKCS7;

            ICryptoTransform cTransform = tdesSp.CreateEncryptor();
            byte[] result_Array = cTransform.TransformFinalBlock(Encrypt_Array, 0, Encrypt_Array.Length);
            

For File protection need to use the below namespace对于文件保护需要使用以下命名空间

using Microsoft.Office.Interop.Excel- excel
using Microsoft.Office.Interop.Word - word

WorkbookObject.Password = password; WorkbookObject.Password = 密码; WorkbookObject.SaveAs("FileName.xls") WorkbookObject.SaveAs("文件名.xls")

for more information on file protection use this link有关文件保护的更多信息,请使用此链接

I was also looking for the solution to this.我也在寻找解决方案。 I found following links helpful:我发现以下链接很有帮助:

https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata

https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata#contentbits https://learn.microsoft.com/en-us/information-protection/develop/concept-mip-metadata#contentbits

We use apache tika as parser, through OOXMLParser we get the metadata of the file.我们使用 apache tika 作为解析器,通过 OOXMLParser 我们得到文件的元数据。

As per the documentation:根据文档:

When a file is labeled with MIP SDK, the only outcomes for contentBits will be 0x0 if the file is unprotected or 0x8 if the file is protected

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Powershell 脚本中添加 Azure 信息保护到 email - Adding Azure Information Protection to email in Powershell Script 在将文件上传到服务器之前,如何检测Word文档是否受密码保护? - How to detect if a Word document is password protected before uploading the file to server? Azure错误,数据保护操作失败 - Azure Error, The Data Protection Operation was unsuccessful Azure应用服务:无法加载文件或程序集Microsoft.Azure.Mobile.Server - Azure App Service: Could not load file or assembly Microsoft.Azure.Mobile.Server .Net Micro与Microsoft Azure - .Net Micro with Microsoft Azure Microsoft Azure SSL配置 - Microsoft Azure SSL configuration 在Azure中读写受密码保护的Excel文件 - Reading & Writing Password Protected Excel Files in Azure 如何检测azure blob存储文件的更改并删除该文件的本地缓存实例? - How do I detect an azure blob storage file change and delete local cache instance of that file? 如何在Microsoft Moles中模拟私有或受保护的类变量? - How to mock private or protected class variable in Microsoft moles? mscorlib:无法加载文件或程序集“Microsoft.Azure.WebJobs,版本=3.0.2.0 - mscorlib: Could not load file or assembly 'Microsoft.Azure.WebJobs, Version=3.0.2.0
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM