2014-07-18 247 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