1

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

情景。我有一个在 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;

AuthDelegate 实现

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;
}

同意委托实施

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

1 回答 1

0

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

于 2019-07-22T13:16:42.300 回答