ASP.NET Windows身份验证注销 [英] ASP.NET Windows Authentication logout

查看:955
本文介绍了ASP.NET Windows身份验证注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你如何在ASP.NET中使用Windows身份验证这样的web.config文件时,注销?

How do you logout when using Windows authentication in ASP.NET like this web.config?

<authentication mode="Windows" />

我已经尝试过失败以下。它重定向,但不注销用户。

I've already tried the following unsuccessfully. It redirects, but does not log out the user.

void logoutButton_Click(object sender, EventArgs e) {
    HttpContext.Current.Session.Clear();
    HttpContext.Current.Session.Abandon();
    ViewState.Clear();
    FormsAuthentication.SignOut();
    Response.Redirect("/");
}

背景资料:

我有,因为我需要模拟使用Active Directory来访问本地文件的身份使用Windows身份验证。我无法模拟使用窗体身份验证,因为 HttpContext.Current.User.Identity 将不会是一个的WindowsIdentity
<一href=\"http://stackoverflow.com/questions/1066275/impersonate-using-forms-authentication\">http://stackoverflow.com/questions/1066275/impersonate-using-forms-authentication

I have to use Windows authentication because I need to impersonate the identity using Active Directory to gain access to local files. And I cannot impersonate using Forms authentication because the HttpContext.Current.User.Identity won't be a WindowsIdentity. http://stackoverflow.com/questions/1066275/impersonate-using-forms-authentication

推荐答案

使用的Windows身份验证时,没有服务器端注销按钮会工作。如果你想有一个注销按钮,你必须使用表单认证,或关闭用户的浏览器。

No server-side logout button will work when using "Windows" authentication. You must use "Forms" authentication if you want a logout button, or close the user's browser.

这篇关于ASP.NET Windows身份验证注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆