从Windows身份验证应用程序注销

时间:2011-07-04 09:46:53

标签: asp.net-mvc active-directory windows-authentication

我想开发一个web应用程序,用户可以使用来自活动目录或注销的数据自动登录,以获得一个表单,用户可以输入其他用户数据作为另一个用户登录。 我在web.config中设置了

<authentication mode="Windows"/>
<authorization>
  <deny users="?" />
</authorization>

但后来我总是闯入。如何注销并打开一个简单的表格来输入另一位用户的用户数据?

2 个答案:

答案 0 :(得分:4)

您无法使用Windows身份验证注销,这就是此类身份验证的全部理念:您登录Windows,从现在开始,它就是单点登录。您需要在其他用户下打开浏览器。

如果要启用此功能,可以使用带模拟的AD表单身份验证。

答案 1 :(得分:0)

我能够使这个工作,但它只适用于IE,而不是FireFox或我所知道的其他。

<input id="LogoutButton" type="button" value="Log Out" />

<script>
    $(document).ready(function () {

        $("#LogoutButton").bind("click", function () {


            try {
                if (window.XMLHttpRequest) {
                    alert("You have been logged off from the website");
                    document.execCommand("ClearAuthenticationCache", "false");
                    window.location = "http://www.stackoverflow.com"
                    if (top.location != location) {
                        top.location.href = ".";


                    }
                    window.location = "http://www.stackoverflow.com"
                }

            }
            catch (e) {
                alert("This feature requires IE 6.0 SP1 or above. " + "Please close all browser windows in order to complete the logout process.");
            }
        });

    });
</script> 
相关问题