简体   繁体   English

ASP.NET Windows身份验证+服务器始终获取匿名用户

[英]ASP.NET Windows Authentication + server always getting anonymous user

Here's my scenario: 这是我的情况:

I have an intranet application. 我有一个Intranet应用程序。 I want to let the network users automatically get logged into the application using the Windows Authentication features. 我想让网络用户使用Windows身份验证功能自动登录到应用程序。 If the user isn't into my network, I'll pop up to them a login screen. 如果用户不在我的网络中,我将向他们弹出一个登录屏幕。

So, I changed the authentication mode into web.config file to Windows . 因此,我将身份验证模式更改为web.config文件,并将其更改为Windows Then I'm using the HttpContext.User.Identity object in order to get the logged user into the network. 然后,我使用HttpContext.User.Identity对象,以使登录的用户进入网络。 So I ran the app into my localhost and it works great. 因此,我将应用程序运行到了我的本地主机中,并且运行良好。

When I publish the application into the server, when I try to automatic log in, the Identity object is always empty. 当我将应用程序发布到服务器中时,当我尝试自动登录时, Identity对象始终为空。

So, I've tried the following steps: 因此,我尝试了以下步骤:

  1. Deny anonymous users. 拒绝匿名用户。 <deny users="?"/> , which not allows any anonymous users to enter in the application, but I got a problem here: when the user isn't into our network, the server pops up that default authentication window from Window Servers, not my personal login screen. <deny users="?"/> ,它不允许任何匿名用户进入应用程序,但是我在这里遇到了一个问题:当用户不在我们的网络中时,服务器会从Window Servers弹出该默认身份验证窗口,而不是我的个人登录屏幕。

  2. Let anonymous users in. If I get rid with that <deny users="?"/> , any user can access the page, but it ALWAYS goes to the login screen, even if I'm into my local network. 让匿名用户进入。如果我放弃了该<deny users="?"/> ,则任何用户都可以访问该页面,但是即使我进入本地网络,它也始终会进入登录屏幕。

So, what I need is: when the user is into the local network, go straight without login. 因此,我需要的是:当用户进入本地网络时,无需登录即可直接进入。 If they aren't, pop up a login screen to them. 如果不是,则弹出一个登录屏幕。

Can someone help me to figure out what's going on? 有人可以帮我弄清楚发生了什么吗?

Thank you all! 谢谢你们!

Do the following, 请执行下列操作,

<identity impersonate="true" />
<authentication mode="None" />
<authorization>
  <deny users="?" />
</authorization>

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM