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




  • 相关阅读:
    C#下实现ping功能
    Telnet Chat Daemon
    ADO.NET连接池
    很好使的MAIL CLASS
    实例看多态
    完整的TCP通信包实现
    使用C#进行点对点通讯和文件传输(通讯基类部分)(转)
    特洛伊木马服务器源代码(C#)
    [C#] 如何选择一个目录
    如何使用C#压缩文件及注意的问题!
  • 原文地址:https://www.cnblogs.com/sunjunlin/p/2348538.html
Copyright © 2011-2022 走看看