首页 > 其他 > 详细

sharepoint 2013 Form认证 注销用户凭证

时间:2014-07-31 13:30:46      阅读:419      评论:0      收藏:0      [点我收藏+]

在网上找到一个关于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

sharepoint 2013 Form认证 注销用户凭证

原文:http://blog.csdn.net/chenxinxian/article/details/38312841

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!