User.Identity.Name使用Windows身份验证 [英] User.Identity.Name with windows authentication

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

问题描述

我有我的头叫AccountInfoPanel一个非常简单的局部视图。
它只有一行:

I have a very simple partial view in my header called AccountInfoPanel. It only has one line:

Welcome: @HttpContext.Current.User.Identity.Name

和在我的web.config我有

And in my Web.Config I have

<authentication mode="Windows" />

但身份名称始终是空的。
如果我通过VS 2012调试,并在指数突破的动作,我看到它是空的。

But the identity name is always empty. If I debug through VS 2012, and break on the index action, I see it is empty.

如果我使用Windows身份验证和启用匿名身份验证diabled运行它通过IIS,我得到一个挑战。
所以我尽量在我的帐户或TEST1和TEST2帐户堵塞。
它回来,说:

If I run it through IIS with Windows Authentication Enabled and Anonymous Authentication diabled, I get a challenge. So I try to plug in My account or a test1 and test2 account. It comes back and says:

HTTP错误401.1 - 未授权
您没有权限使用您提供的凭据查看该目录或网页。

HTTP Error 401.1 - Unauthorized You do not have permission to view this directory or page using the credentials that you supplied.

我也尝试设置模拟为真,并从挑战同样的反应。
有谁知道如何设置呢?

I also tried setting Impersonation to true and get the same response from the challenge. Does anyone know how to set this up?

如果所有的设置在IIS做的都有,你怎么调试code Visual Studio中?

And if all the setup has to done in IIS, how do you debug your code within Visual Studio?

另外一个问题。我的老板似乎认为你甚至不需要登录框。 IE浏览器将只知道你是谁。而你可以运行方式在IE中使用不同的帐户。

One other question. My boss seems to think you don't even need a login box. IE would just know who you are. And you could "run as" in IE with a different account.

推荐答案

在我的清单中可能出现的问题选中一个

Check one of possible issues on my checklist

<一个href=\"http://netpl.blogspot.com/2012/06/iis-75-integrated-security-with-no.html\">http://netpl.blogspot.com/2012/06/iis-75-integrated-security-with-no.html

在短:

首先,确保匿名身份验证被关闭的网站:

First, make sure that Anonymous Authentication is turned OFF for the site:

二,启用Interner Explorer中集成安全(选项/高级,并签了启用集成Windows身份验证选项)。

Second, enable integrated security in Interner Explorer (Options/Advanced and checkin the "Enable Integrated Windows Authentication" option).

三,增加你的网站,本地Intranet区域,并至少选择自动登录只在Intranet区域选项下/安全设置/本地Intranet /自定义级别)选项。

Third, add your website to Local Intranet zone and select at least "Automatic logon only in Intranet Zone" option under Options/Security Settings/Local intranet/Custom level).

四,确保用户和应用服务器在同一个域中。

Fourth, make sure the user and application server are in the same domain.

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

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