Microsoft.InformationProtection.Exceptions.AccessDeniedException: 服务不接受授权令牌
Microsoft.InformationProtection.Exceptions.AccessDeniedException: The service didn't accept the auth token
我想扩展现有的迁移工具以在文件导入 Sharepoint Online 之前设置敏感度标签。我找到了 Microsoft Information Protection SDK,它似乎提供了必要的 API.
为了熟悉 API,我下载并 运行 ServicePrincipalAuth 示例应用程序(参见 https://docs.microsoft.com/en-us/samples/azure-samples/mipsdk-dotnet-file-serviceprincipalauth/mipsdk-dotnet-file-serviceprincipalauth/)。但是,尽管我完全按照这些步骤进行操作,但我总是在第
行的 CreateFileEngine 方法中收到带有消息“服务不接受身份验证令牌”的 AccessDeniedException
var engine = Task.Run(async () => await profile.AddEngineAsync(engineSettings)).Result;
到目前为止,我已经尝试了两种身份验证变体(证书和密钥)。两者的结果相同。
我的 App.config 文件如下所示:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<appSettings>
<add key="ida:ClientId" value="[client ID from Azure AD app]"/>
<add key="ida:RedirectUri" value="mipsdk-auth-sample://authorize2"/>
<add key="ida:CertThumbprint" value="[thumbprint of my self-signed certificate]"/>
<add key="ida:ClientSecret" value="[client secret from Azure AD app]"/>
<add key="ida:DoCertAuth" value="true"/>
<add key="ida:Tenant" value="[my tenant name].onmicrosoft.com"/>
<add key="app:Name" value="mipsdk-auth-sample2"/>
<add key="app:Version" value="1.0.0"/>
</appSettings>
</configuration>
更新:
我们的管理员需要同意 Azure AD 应用请求的 API 权限。完成此操作后,身份验证按预期工作!
不幸的是,我运行进入了一个新的错误:
RMS 服务已禁用,无法为此用户发布。,CorrelationId=e2e...,CorrelationId.Description=FileHandler,HttpRequest.Id=00d...,ServiceDisabledError.Extent=用户
这次在 SetLabel 方法中的行:
var result = Task.Run(async () => await handler.CommitAsync(options.OutputName)).Result;
错误信息建议为用户启用RMS服务。我(或我们的管理员)如何为 Azure AD 应用执行此操作?
非常感谢任何提示!
您看到的错误是因为在 RMS 服务中启用了入职控制策略。
您需要跟进您的管理员,询问他们如何配置策略。如果他们设置了一个组,您需要将服务主体添加到作为入职控制的一部分启用的 AAD 组。
我想扩展现有的迁移工具以在文件导入 Sharepoint Online 之前设置敏感度标签。我找到了 Microsoft Information Protection SDK,它似乎提供了必要的 API.
为了熟悉 API,我下载并 运行 ServicePrincipalAuth 示例应用程序(参见 https://docs.microsoft.com/en-us/samples/azure-samples/mipsdk-dotnet-file-serviceprincipalauth/mipsdk-dotnet-file-serviceprincipalauth/)。但是,尽管我完全按照这些步骤进行操作,但我总是在第
行的 CreateFileEngine 方法中收到带有消息“服务不接受身份验证令牌”的 AccessDeniedExceptionvar engine = Task.Run(async () => await profile.AddEngineAsync(engineSettings)).Result;
到目前为止,我已经尝试了两种身份验证变体(证书和密钥)。两者的结果相同。
我的 App.config 文件如下所示:
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
<appSettings>
<add key="ida:ClientId" value="[client ID from Azure AD app]"/>
<add key="ida:RedirectUri" value="mipsdk-auth-sample://authorize2"/>
<add key="ida:CertThumbprint" value="[thumbprint of my self-signed certificate]"/>
<add key="ida:ClientSecret" value="[client secret from Azure AD app]"/>
<add key="ida:DoCertAuth" value="true"/>
<add key="ida:Tenant" value="[my tenant name].onmicrosoft.com"/>
<add key="app:Name" value="mipsdk-auth-sample2"/>
<add key="app:Version" value="1.0.0"/>
</appSettings>
</configuration>
更新:
我们的管理员需要同意 Azure AD 应用请求的 API 权限。完成此操作后,身份验证按预期工作!
不幸的是,我运行进入了一个新的错误:
RMS 服务已禁用,无法为此用户发布。,CorrelationId=e2e...,CorrelationId.Description=FileHandler,HttpRequest.Id=00d...,ServiceDisabledError.Extent=用户
这次在 SetLabel 方法中的行:
var result = Task.Run(async () => await handler.CommitAsync(options.OutputName)).Result;
错误信息建议为用户启用RMS服务。我(或我们的管理员)如何为 Azure AD 应用执行此操作?
非常感谢任何提示!
您看到的错误是因为在 RMS 服务中启用了入职控制策略。
您需要跟进您的管理员,询问他们如何配置策略。如果他们设置了一个组,您需要将服务主体添加到作为入职控制的一部分启用的 AAD 组。