2011-07-04 48 views
2

我想开发一个Web应用程序,用户可以使用活动目录中的数据或注销自动登录以获取表单,其中用户可以输入其他用户数据以作为另一个用户登录。 我在web.config中的从Windows身份验证应用程序注销

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

但后来我总是loged在设置。我怎么能注销并打开一个简单的形式进入其他用户的用户数据?

回答

4

你不能注销与Windows身份验证,这是这种类型的身份验证的整个想法:你登录到Windows,从现在开始它是一个单一登录。您需要在其他用户下打开浏览器。

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

+0

这种测试windows auth应用程序使测试更棘手。 – ProfK

+0

如果您是通过不属于域的设备访问网站的(例如我们的案例中的Android平板电脑),那么AD登录的工作方式与提示输入用户名和密码的表单登录类似。在这种情况下,让用户注销确实有意义。 –

0

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

<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> 
+0

这个答案在IE 11中不起作用。我认为这是非常古老的答案,并且可能在旧的ie版本中工作。 –

相关问题