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();");




  • 相关阅读:
    学习shell script
    ubuntu11.10安装出现/cdrom问题以及不能格式成ext问题
    正则表达式
    认识与学习bash(2)
    UNIX网络编程 一个简单的时间获取客户程序
    HDU4522
    恢复引导
    认识与学习bash(1)
    文件格式化处理
    C++解析csv文件
  • 原文地址:https://www.cnblogs.com/sunjunlin/p/2348538.html
Copyright © 2011-2022 走看看