zoukankan      html  css  js  c++  java
  • Sharepoint 2010完全登出

    When you using Windows Authentication  (NTLM + AD) with your sharepoint site you may want to enter credential after  you sign out from your site.But it is not easy and somehow imposible when using authentication NTLM and IE .Beacuse after you sign out and try to login again ,automatic login proccess logs you in immediately.

    1) Edit your v4.master and add fallowing js codes. (Using JQuery)

    <script type="text/javascript" src="/_catalogs/Scripts/jquery.js"></script>
    <script type="text/javascript" >
    $(document).ready(function(){$("#zz15_ID_Logout").attr("onMenuClick","STSNavigate2(event,'/SitePages/logout.aspx');");});
    </script>
    

    但是上面的zz15_ID_Logout可能是错的,所以我用了个方法测试这个ID到底是什么?

    var obj = document.getElementsByTagName("ie:menuitem");
     
    for (var i = 0; i < obj.length; i++)
    {
    menuItem = obj [i];
    
    //To hide the Sign out and Sign in as Different user menu items.
    if (menuItem.id.match("Logout")!=null | menuItem.id.match("LoginAsDifferentUser")!=null)
    { menuItem.hidden=true; 
    
    }
    }
    

    发现他们是:

    zz13_ID_LoginAsDifferentUser
    zz14_ID_Logout

    2) create a new “logout.aspx” page which masterpage is v4.master using Sharepoint Designer

    3) add the fallowing code to your new sign out page

    <script type="text/javascript">
    function _spBodyOnLoad()
    {
    try
    {
       /* Note : this command is support with only IE  */
      document.execCommand("ClearAuthenticationCache",false);
    }
      catch (e) { }
      window.location='/_layouts/signout.aspx'; 
    }
    </script>
    

      4) For testing choose a different machine than sharepoint server and configure your browser Tools->Internet Options->Security->Local Intranet
    Click Custom Level and find Logon and change it to “Prompt for user name and password”
    And be sure your site not added to trusted zone sites.


    但是这种方法全强制清除所有的cookies,且只能应用于IE,所以这个方法不是很好。


    经测试,发现如果welcome.ascx的菜单个数不同则不能找到相关的菜单,原因是菜单的ID是根据权限不同,显示不同的菜单,菜单个数不同,则菜单ID不同,所以改良了一下:

    $("[id*='ID_Logout']").attr("onMenuClick","removeCookiesAndLogOut();");
    $("[id*='ID_LoginAsDifferentUser']").attr("onMenuClick","removeCookiesSingAsDiffUser();");




  • 相关阅读:
    07-0.部署 worker 节点
    06-4.部署高可用 kube-scheduler 集群
    06-3.部署高可用 kube-controller-manager 集群
    vim 查找并替换多个匹配字符
    vim 行号的显示与隐藏
    Python学习【第4篇】:元组魔法
    Python学习【第3篇】:列表魔法
    Python学习【第2篇】:基本数据类型(详解)
    pycharm设置头文件模板(for mac)
    pycharm创建文件夹以及查看源文件存放位置(FOR MAC)
  • 原文地址:https://www.cnblogs.com/sunjunlin/p/2348538.html
Copyright © 2011-2022 走看看