WAAD Logout重定向到office 365登录页面

时间:2014-09-15 13:33:01

标签: authentication wif logout ws-federation

使用WSfederationAuthentication来解决从我的应用程序注销的问题。注销时,我执行以下代码:

FormsAuthentication.SignOut();

            if (FederatedAuthentication.SessionAuthenticationModule != null)
            {
                FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie();
                FederatedAuthentication.SessionAuthenticationModule.SignOut();
            }

            if (FederatedAuthentication.WSFederationAuthenticationModule != null)
            {
                WSFederationAuthenticationModule authModule =
                    FederatedAuthentication.WSFederationAuthenticationModule;
                authModule.SignOut(true);

                String signoutURL = WSFederationAuthenticationModule.GetFederationPassiveSignOutUrl(
                    authModule.Issuer,
                    authModule.Realm",
                    null);

                WSFederationAuthenticationModule.FederatedSignOut(
                    new Uri(signoutURL),
                    new Uri(authModule.Realm));                    
            }

Cookie被清除等,但页面被重定向到office365登录页面,而不是我的应用程序正确的登录页面。

发行人和领域是正确的     发行人:https://login.windows.net/EndpointID/wsfed     领域:https //:localhost:444(我的应用程序的基地址,localhost)

点击退出后,以下是fiddler日志:

http://login.windows.net:443
https://login.windows.net/EndpointID/wsfed?wa=wsignout1.0&wreply=https%3a%2f%2f127.0.0.1%3a444%2f
https://localhost:444/?wa=wsignoutcleanup1.0
http://login.microsoftonline.com:443
https://login.microsoftonline.com/login.srf?wa=wsignout1.0
https://login.microsoftonline.com/logout.srf?wa=wsignout1.0&lc=1033
https://login.windows.net/common/wsfed?wa=wsignoutcleanup1.0  **<<<<------ Why ?**
http://login.microsoftonline-p.com:443 
https://login.microsoftonline-p.com/ThirdPartyCookieCheck.srf?ct=9348739876
https://login.microsoftonline-p.com/ThirdPartyCookieCheck.srf?tpc=394875457987&lc=1033
https://login.microsoftonline.com/?lc=1033

这些家伙面临类似的问题,没有解决方案: http://social.msdn.microsoft.com/Forums/vstudio/en-US/ac41c0c5-83ef-4394-9111-fa6d07215f5d/adfs-20-does-not-redirect-back-to-reply-url-on-signout?forum=Geneva

1 个答案:

答案 0 :(得分:0)

如果没有回复,我可以假设没有人遇到过这个问题:D。

我为那些在这里寻找相同的人找到了解决方案。

所以根据&#39; WSFederationAuthenticationModule.FederatedSignOut&#39; MSDN上的文档:

  

调用此方法将WS-Federation签出请求消息发送到指定的STS。您可以选择为注销请求中的wreply参数提供值。该方法执行以下操作:

     
      
  1. 使用指定的参数创建WS-Federation签名请求消息。

  2.   
  3. 调用SAM上的SessionAuthenticationModule.DeleteSessionTokenCookie方法以删除会话cookie。

  4.   
  5. 使用第一步中的退出请求消息重定向到STS。

  6.   

由于某些原因,我没有像宣传的那样工作:(。所以我决定手动完成这三件事情,完美无缺。问题现在已经解决了,但仍然想知道为什么提供的封装器不起作用。

FederatedAuthentication.SessionAuthenticationModule.DeleteSessionTokenCookie();
FederatedAuthentication.SessionAuthenticationModule.SignOut();

WSFederationAuthenticationModule wsfederationAuthenticationModule = FederatedAuthentication.WSFederationAuthenticationModule;
wsfederationAuthenticationModule.SignOut(true);
signOutRequestMessageuestMessage signOutRequestMessage = new signOutRequestMessageuestMessage(new Uri(wsfederationAuthenticationModule.Issuer));
signOutRequestMessage.Parameters.Add("wreply", wsfederationAuthenticationModule.Realm);
signOutRequestMessage.Parameters.Add("wtrealm", wsfederationAuthenticationModule.Realm);
signOutURI = signOutRequestMessage.WriteQueryString();
Redirect(signOutURI)

希望这有帮助。

拉​​夫

相关问题