1

我使用本指南为 ADFS 构建了 MFA 扩展:https ://blogs.msdn.microsoft.com/jenfieldmsft/2014/03/24/build-your-own-external-authentication-provider-for-ad-fs-在-windows-server-2012-r2-walk-through-part-1/

我正在尝试获取传入的声明以获取IAuthenticationAdapter.BeginAuthentication(Claim claim, ...)正在验证的用户的电子邮件。根据指南,我应该能够在我的元数据中指定IdentityClaims要返回的内容"http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress",然后我应该会收到电子邮件。

但是,我的代码永远不会被击中。

相反,我在事件查看器日志中收到以下错误:

System.IO.InvalidDataException: The identity information provided does not contain a Windows account name.
   at Microsoft.IdentityServer.Web.Authentication.External.ExternalAuthenticationHandler.ProcessContext(ProtocolContext context, IAuthenticationContext authContext, IAccountStoreUserData userData)
   at Microsoft.IdentityServer.Web.Authentication.External.ExternalAuthenticationHandler.Process(ProtocolContext context)
   at Microsoft.IdentityServer.Web.Authentication.AuthenticationOptionsHandler.Process(ProtocolContext context)
   at Microsoft.IdentityServer.Web.PassiveProtocolListener.OnGetContext(WrappedHttpListenerContext context)

我尝试指定依赖方信任以传递 LDAP 参数,但我无法在我的代码中访问这些参数。

有什么建议么?

4

1 回答 1

0

背景

我们自己在尝试调试这个确切的问题时遇到了这个问题。我们正在试验IAuthenticationAdapterMetadata.IdentityClaims. 当我们的适配器请求emailaddress作为我们的输入声明时,ADFS 在调用BeginAuthentication.

主要问题是我们的声明提供程序(在本例中为 Active Directory)未配置为提供用户的电子邮件地址。我们在 Microsoft(免费) Claims X-Ray服务的帮助下发现了这一点,我强烈建议那些调试 ADFS 声明问题的人使用该服务。

其次,ADFS 给出了误导性错误。ADFS 实际上似乎并未验证Claim传递给BeginAuthentication. 一旦我们解决了主要问题,只要定义了用户的电子邮件地址,就没有限制。

解决方案

注意:如果您有多个索赔提供者信托,您可能需要对它们中的每一个都执行此操作。

  1. 导航到AD FS Management相关机器上的应用程序。
  2. 选择Claims Provider Trusts
  3. 右键单击要“修复”的提供程序并选择Edit Claim rules...
  4. 选择Add Rule...,然后选择Send LDAP Attributes as Claims
  5. 我假设您应该选择您正在处理的提供程序作为Attribute store此规则。如果不能,您可能需要进行试验。
  6. 将LDAP 属性映射E-Mail-Addresses到声明类型E-Mail Address
  7. 保存新规则。

附加说明:只有E-Mail-Addresses数组中的第一个值会被发送到BeginAuthentication. 这似乎是界面的一个怪癖,而不是这个解决方案的怪癖。

于 2019-08-23T21:35:07.127 回答