【发布时间】:2011-11-07 14:09:08
【问题描述】:
我正在使用 Windows Identity Foundation 来管理我们网站的登录。
当用户登录时,我会在他的请求中使用一些信息来提出索赔。 一切正常,但现在我需要管理这种情况:
- 用户已经登录、认证并拥有一个有效的令牌。
- 但用户决定再次浏览(通过来自另一个站点的重定向)
- 所以他请求中的信息是不同的。
-
我想要
- 让他退出 - 这样他自然会用他的新信息创建一个新令牌
- 或更新他现有的令牌。
所以我的问题是:
- 如何退出 Windows Identity Foundation?
- 或者如何更新现有声明?
我试过这段代码:
public void ExpireClaims(HttpContextBase httpContextBase)
{
var module =
httpContextBase.ApplicationInstance.Modules["WSFederationAuthenticationModule"] as
WSFederationAuthenticationModule;
if (module == null)
{
return;
}
module.SignOut(true);
}
但是模块总是为空。
我试过这个:
public void FederatedSignOut(string replyUrl)
{
WSFederationAuthenticationModule.FederatedSignOut(null, new Uri(replyUrl));
}
但是当我这样做时,我得到一个空引用执行。
非常感谢。
【问题讨论】: