在网上找到一个关于sharepoint 2013 Form表单认证的sign out 方法,经过验证,有效。方法如下:
private void RemoveCookiesAndSignOut()
{
// Clear sessionstate.
if (Context.Session !=null)
{
Context.Session.Clear();
}
string cookieValue = string.Empty;
if(Context.Request.Browser["supportsEmptyStringInCookieValue"] == "false")
cookieValue = "NoCookie";
// Clear my owncookie.
HttpCookie cookieWinSignIn =Context.Request.Cookies["Morpheus_WindowsSignedIn"];
if (cookieWinSignIn != null)
{
cookieWinSignIn.Value =cookieValue;
Context.Response.Cookies.Remove("Morpheus_WindowsSignedIn");
Context.Response.Cookies.Add(cookieWinSignIn);
}
// Remove cookiesfor authentication.
HttpCookie cookieSession =Context.Request.Cookies["WSS_KeepSessionAuthenticated"];
if (cookieSession != null)
{
cookieSession.Value =cookieValue;
Context.Response.Cookies.Remove("WSS_KeepSessionAuthenticated");
Context.Response.Cookies.Add(cookieSession);
}
HttpCookie cookiePersist =Context.Request.Cookies["MSOWebPartPage_AnonymousAccessCookie"];
if (cookiePersist != null)
{
cookiePersist.Value =cookieValue;
cookiePersist.Expires = newDateTime(1970, 1, 1);
Context.Response.Cookies.Remove("MSOWebPartPage_AnonymousAccessCookie");
Context.Response.Cookies.Add(cookiePersist);
}
// Sign out.
Microsoft.IdentityModel.Web.FederatedAuthentication.SessionAuthenticationModule.SignOut();
}
需要引用以下dll:
C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.SharePoint.IdentityModel\v4.0_15.0.0.0__71e9bce111e9429c\Microsoft.SharePoint.IdentityModel.dll
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IdentityModel.dll
C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation\v3.5\Microsoft.IdentityModel.dll
页面继承IdentityModelSignInPageBase类。
sharepoint 2013 Form认证 注销用户凭证,布布扣,bubuko.com
原文:http://blog.csdn.net/chenxinxian/article/details/38312841