【问题标题】:logout from windows authentication从 Windows 身份验证注销
【发布时间】:2014-07-18 20:18:40
【问题描述】:

在我的公司,我设计了一个 php-mysql-jquery 网站用于内网盘点。 Web 服务器 (iis8) 托管在连接到 Active Directory 的 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 ?

【问题讨论】:

标签: php mysql iis active-directory


【解决方案1】:

如果我明白了。

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

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

【讨论】:

  • 不,我没有使用任何会话。这一切都是通过 IIS windows 身份验证完成的。没有登录密码。
  • 你在使用:$_SERVER['PHP_AUTH_USER']?
猜你喜欢
  • 2010-11-07
  • 1970-01-01
  • 2019-01-31
  • 1970-01-01
  • 2013-09-22
  • 2015-05-25
  • 1970-01-01
  • 2011-06-03
  • 2021-10-08
相关资源
最近更新 更多