Sharepoint 2013 FederatedAuthentication为null

时间:2015-03-31 20:14:03

标签: sharepoint sharepoint-2013 adfs2.0

我所处的环境中,我们通过ADFS服务器对Sharepoint 2013进行了身份验证。当我退出adfs时,我仍然在sharepoint登录。

我的解决方案似乎是使用FederatedAuthentication.SessionAuthenticationModule.SignOut();

然而,当我尝试这个时,我得到的Object引用没有设置为对象的实例。

1 个答案:

答案 0 :(得分:0)

我希望有人能指出我正确的方向。我试图让注册为adfs和sharepoint工作。这是我使用

的代码
  private void RemoveCookiesAndRedirect()
    {
        string ipUrl = GetIPUrl();
        //if (ipUrl != string.Empty)
        //{
        string replyUrl = HttpUtility.UrlEncode(SPContext.Current.Site.RootWeb.Url);
        string redirect = ipUrl + "?wa=wsignout1.0&wreply=" + replyUrl;

        try
        {

                FederatedAuthentication.SessionAuthenticationModule.SignOut();

                if (Context.Session != null) Context.Session.Abandon();

                Context.Response.Redirect(redirect);
            //}
        }
        catch (Exception ex)
        {
            LoggingService.LogError("LoginRedirect", ex.Message + " " + ex.InnerException + " " + ex.Data + " ipUrl:" + ipUrl + " redirect:" + redirect);
        }
    }

    private string GetIPUrl()
    {
        IClaimsPrincipal user = Page.User as IClaimsPrincipal;
        if (user == null) return string.Empty;

        string ipUrl = string.Empty;
        try
        {
            string providerName = (user.Identity.Name).Split('|')[1];
            ipUrl = SPSecurityTokenServiceManager.Local.TrustedLoginProviders[providerName].ProviderUri.AbsoluteUri;
        }
        catch
        {
            //TODO:Log it
        }
        return ipUrl;
    }

每当它到达FederatedAuthentication.SessionAuthenticationModule.SignOut();它出错了。