2014-07-18 175 views
0

在我的公司,我设计了一个用于Intranet库存的php-mysql-jquery网站。 Web服务器(iis8)位于连接到Active Directory的Windows 8计算机中。我需要为我的网站提供AD身份验证,为此,我启用了Windows身份验证功能,以在用户访问我的网站之前对用户进行身份验证。从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> 

是什么/路/是/会/返回/ 200/OK?

+0

试试这个职位:http://stackoverflow.com/questions/449788/http-authentication-logout-via-php – Niels

回答

0

如果我明白了。

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

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

+0

不,我没有使用任何会议。它全部通过IIS Windows身份验证完成。没有用于登录的代码。 – user3784564

+0

您使用的是:$ _SERVER ['PHP_AUTH_USER']? – ivanfromer