从Windows身份验证注销

时间:2014-07-18 20:18:41

标签: php mysql iis active-directory

在我的公司,我为Intranet库存设计了一个php-mysql-jquery网站。 Web服务器(iis8)托管在连接到Active目录的Windows 8计算机中。我需要为我的网站提供AD身份验证,为此我启用了Windows身份验证功能,以便在用户访问我的网站之前对其进行身份验证。

该功能正常运行,用户现在可以登录了!但我需要他们从网站注销。但我无法在互联网上找到任何代码来做到这一点。我现在需要做的是,告诉用户重启浏览器并清除浏览器历史记录。有人对此有所了解吗?还有另一种方法吗?

我试过这段代码

html><head>
<script type="text/javascript">
function logout() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
          xmlhttp = new XMLHttpRequest();
    }
    // code for IE
    else if (window.ActiveXObject) {
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (window.ActiveXObject) {
      // IE clear HTTP Authentication
      document.execCommand("ClearAuthenticationCache");
      window.location.href='/where/to/redirect';
    } else {
        xmlhttp.open("GET", '/path/that/will/return/200/OK', true, "logout", "logout");
        xmlhttp.send("");
        xmlhttp.onreadystatechange = function() {
            if (xmlhttp.readyState == 4) {window.location.href='/where/to/redirect';}
        }


    }


    return false;
}
</script>
</head>
<body>
<a href="#" onclick="logout();">Log out</a>
</body>
</html>

什么是/ path / that / will / return / 200 / OK?

1 个答案:

答案 0 :(得分:0)

如果我理解的话。

您是否在$ _SESSION中存储变量以保持用户的记录?

如果是,您可以创建一个注销文件并将Session destroy。 如果您使用的是cookies,则需要在注销文件中清除cookie。