Windows Azure Active Directory单一登录 - 用于登录错误的自定义错误页面

时间:2013-07-16 16:08:22

标签: asp.net-mvc azure active-directory single-sign-on azure-active-directory

我们已成功设置Windows Azure AD租户,并根据本教程http://msdn.microsoft.com/en-us/library/windowsazure/dn151790.aspx

在我们的ASP.NET应用程序中实现了网络单点登录

我们正在使用组织身份进行身份验证,但如果用户已使用其他Microsoft帐户(Windows Live ID)登录到其他网站,则会收到非常用户不友好的错误消息。 - “ACS20016:登录用户的域与此STS的任何允许域都不匹配。”

我们有什么方法可以提供更友好的用户错误消息吗?如果在登录过程中发生错误,是否有类似ACS中的错误URL将用户重定向到自定义错误页面?

1 个答案:

答案 0 :(得分:0)

完全可能。

ACS为您提供编码JSON中的错误消息 像这样

{"context":null,"httpReturnCode":401,"identityProvider":"Google","timeStamp":"2010-12-17 21:01:36Z","traceId":"16bba464-03b9-48c6-a248-9d16747b1515","errors":[{"errorCode":"ACS30000","errorMessage":"There was an error processing an OpenID sign-in response."},{"errorCode":"ACS50019","errorMessage":"Sign-in was canceled by the user."}]}
  1. 首先,您需要在管理门户中为您的ACS命名空间启用“错误网址功能” - >编辑依赖方 - >错误网址。
  2. 您需要一个辅助类来解码JSON。 steps here
  3. 配置匿名访问权限错误页面。
  4. 通过此功能,您可以完全控制页面,您可以按照所需的方式显示错误消息,并将页面标记为与依赖方网站的外观相匹配。