You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET Web应用中Office敏感度标签可获取但无法应用问题求助

.NET Web应用应用Office敏感度标签时触发ServiceDisabledException错误

我正在.NET Web应用中尝试为文件应用Office敏感度标签,参考了MIP SDK的官方示例项目。应用注册已配置项目要求的权限,能正常获取可用标签,但在给文件流应用标签时,出现以下错误:

Microsoft.InformationProtection.Exceptions.ServiceDisabledException: 'Calling principal is forbidden to perform the operation, CorrelationId=616b22f2-cbf0-4636-b959-a90adc68456f, CorrelationId.Description=FileHandler, HttpRequest.Id=d8d6666c-4b94-4ee1-8b4b-d7b1645acadf, ServiceDisabledError.Extent=User'

不确定错误根源是代码问题还是应用注册仍缺少权限,相关函数代码如下:

public MemoryStream ApplyMipLabel(Stream inputStream, string labelId)
{
    IFileEngine engine = GetEngine(_defaultEngineId);

    // 创建文件处理器,使用硬编码文件名和输入流
    IFileHandler handler = engine.CreateFileHandlerAsync(inputStream, "HrData.xlsx", false).GetAwaiter().GetResult();

    LabelingOptions options = new()
    {
        AssignmentMethod = AssignmentMethod.Standard
    };

    // 获取指定ID的标签并设置到处理器
    var label = engine.GetLabelById(labelId);
    handler.SetLabel(label, options, new ProtectionSettings());

    MemoryStream outputStream = new MemoryStream();

    // 提交更改并写入输出流,错误发生在此行
    handler.CommitAsync(outputStream).GetAwaiter().GetResult(); 
    return outputStream;
}

内容的提问来源于stack exchange,提问作者Valyrion

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.01 12:22:24