【问题标题】:Error protecting file using MIP SDK in service/daemon application在服务/守护程序应用程序中使用 MIP SDK 保护文件时出错
【发布时间】:2019-07-22 21:17:24
【问题描述】:

有人可以帮我解决以下问题吗?

场景。我有一个在 Azure VM 上运行的 Windows 服务。服务接收文件,以某种方式修改它们(假设它向 Word 文件添加自定义属性)并使用 MIP SDK 使用模板 ID 保护它们。

问题IFileHandler.SetProtection(string)+CommitAsync(...) 失败并出现以下异常:

发生了一个或多个错误。 ServiceDiscoveryHelper::GetServiceDetails - 无法计算域:许可证域、身份和云端点基本 URL 均为空,correlationId:[9add32ba-0cb7-4d31-b9d8-0000b7c694a4]

其他信息

主代码片段

MIP.Initialize(MipComponent.File);

var appInfo = new ApplicationInfo{
    ApplicationId = ConfigurationManager.AppSettings["AppPrincipalId"],
    ApplicationName = "App name",
    ApplicationVersion = "1.0.0",
};

var authDelegate = new AuthDelegateImplementation(appInfo);
var fileProfileSettings = new FileProfileSettings("mip_data", false,
    authDelegate, new ConsentDelegateImplementation(), appInfo, LogLevel.Trace);

var fileProfile = MIP.LoadFileProfileAsync(fileProfileSettings).Result;
var engineSettings = new FileEngineSettings("engine-id", "", "en-US"){
    Identity = new Identity($"{appInfo.ApplicationId}@<TENANT-NAME>"){
        DelegatedEmail = "<OWNER>@<TENANT-NAME>",
    },
};
var fileEngine = fileProfile.AddEngineAsync(engineSettings).Result;
var fileHandler = fileEngine.CreateFileHandlerAsync("c:\\sample.docx", "0", true).Result;
fileHandler.SetProtection(new ProtectionDescriptor("<TEMPLATE-ID>"));
var success = fileHandler.CommitAsync("c:\\encrypted.docx").Result;

AuthDelegateImplementation

public string AcquireToken(Identity identity, string authority, string resource)
    var authContext = new AuthenticationContext(authority + "/" + "<TENANT_ID>");
    var clientCredential = new ClientCredential("<CLENT_ID>", "<CLIENT_SECRET>");
    var res = await authContext.AcquireTokenAsync(resource, clientCredential);
    return res.AccessToken;
}

ConsentDelegateImplementation

public class ConsentDelegateImplementation : IConsentDelegate {
    public Consent GetUserConsent(string url) {
        return Consent.Accept;
    }
}

【问题讨论】:

    标签: azure-information-protection microsoft-information-protection


    【解决方案1】:

    在测试 MIP 的本地持久状态(当 UseInMemoryStorage 为 flase 时,请参阅 FileProfileSettings.Path 属性)后,它接缝已损坏。删除“mip_data”文件夹后问题消失了。

    【讨论】:

    • 我在 PDF 文件上设置标签时遇到了这个问题。删除文件夹没有帮助。仍然想知道它可能是什么
    • 我们可以将自定义电子邮件地址应用为水印内容,而不是从 protection.office.com 吗?
    猜你喜欢
    • 2015-03-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多