简体   繁体   English

ASP.Net Windows 身份验证 - 用户身份登录到服务器

[英]ASP.Net Windows Authentication - User Identity Logged Into Server

I have an ASP.Net application that is using Windows Authentication and I have specified a role that is on my AD and on my local development box, all appears to be well.我有一个使用 Windows 身份验证的 ASP.Net 应用程序,并且我在我的 AD 和本地开发框中指定了一个角色,一切似乎都很好。 When I deploy to my test web server, the username that is displayed via the ASP LoginName control is showing an identity that is local to the server, not my actual account on the domain in which I am currently logged in as on my local pc.当我部署到我的测试 web 服务器时,通过 ASP LoginName 控件显示的用户名显示的是服务器本地的身份,而不是我当前在本地 PC 上登录的域上的实际帐户。 What gives?是什么赋予了?

UPDATE: I am using Windows XP SP3 with the development IIS server (not IIS, even though IIS is installed).更新:我正在使用 Windows XP SP3 和开发 IIS 服务器(不是 IIS,即使 Z5DA5ACF46104EFB7E7Z6EC8 已安装)。 I created a new test site (empty web template from VWD2010 Express).我创建了一个新的测试站点(来自 VWD2010 Express 的空 web 模板)。 Only configuration I did so far was on the Default.aspx page, I added:到目前为止,我所做的唯一配置是在 Default.aspx 页面上,我补充说:

<asp:LoginName ID="LoginName1" runat="server" FormatString="Welcome {0}!" /><br />
<asp:Label ID="RoleLabel" runat="server"></asp:Label>

And then in the code behind, I added:然后在后面的代码中,我添加了:

if (User.IsInRole("IPSCODOM\\SAFETY OBSERVATION"))
{
    this.RoleLabel.Text = "You are in the SAFETY OBSERVATION role";
}
else {
    this.RoleLabel.Text = "You are NOT in the proper role!";
}

Now, when I start debugging, the screen shows the following:现在,当我开始调试时,屏幕显示如下:

This is the output I was expecting.这是我期待的 output。 BUT, when I deploy the site (again, no other configuration to the website) to the test server (Server 2003 R2 with IIS 6.1) the results are quite different.但是,当我将站点(同样,网站没有其他配置)部署到测试服务器(带有 IIS 6.1 的 Server 2003 R2)时,结果完全不同。 The user returned is a user that we use to login to that server (but is a domain account).返回的用户是我们用来登录该服务器的用户(但是是域帐户)。 The Application Pool is set to login using the Network Service account (which I have tried all three, System, Local Service, and Network Service) and the World Wide Web Publishing Service is using the Local System account to login.应用程序池设置为使用网络服务帐户(我已经尝试了所有三个,系统、本地服务和网络服务)登录,并且 World Wide Web 发布服务使用本地系统帐户登录。 I disabled Anonymous access on the site and when I browse to the site, again, it shows a different user account than my logged in user account.我在网站上禁用了匿名访问,当我浏览到该网站时,它再次显示与我登录的用户帐户不同的用户帐户。

What am I doing wrong?我究竟做错了什么?

What "local to the server" identity.什么“本地服务器”身份。 Without knowing much about your set up, I would first check that you do have the IIS instance on the server set to use Windows Authentication, as that is NOT the default.在不了解您的设置的情况下,我会首先检查您是否将服务器上的 IIS 实例设置为使用 Windows 身份验证,因为这不是默认设置。 If fixing that fails, then make sure you have not hotwired the service in IIS to use a specific account.如果修复失败,请确保您没有将 IIS 中的服务热连线以使用特定帐户。

Actual issue was that when I needed to deploy some files over to the test server and I did not have access to the root of the drive.实际问题是,当我需要将一些文件部署到测试服务器并且我无权访问驱动器的根目录时。 When I browsed to the root, the login dialog appeared and I logged in as the user that it was showing as logged in on the web page.当我浏览到根目录时,出现了登录对话框,我以在 web 页面上显示为已登录的用户身份登录。 I forgot that I did this and now I feel like an idiot.我忘了我做了这个,现在我觉得自己像个白痴。 Please excuse my ignorance but keep this question in mind in case someone else has a brain fart.请原谅我的无知,但请记住这个问题,以防其他人放屁。

To undo the login by the way, I went to Control Panel >> User Accounts >> Advanced >> Manage Passwords and removed the credentials for the server I was browsing to.顺便说一句,要撤消登录,我转到控制面板>>用户帐户>>高级>>管理密码并删除了我正在浏览的服务器的凭据。 Then it picked up my user account properly.然后它正确地拿起了我的用户帐户。

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

相关问题 IIS7上的ASP.NET身份验证问题-Windows身份验证的User.Identity.Name为空 - ASP.NET Authentication Issues on IIS7 - User.Identity.Name is empty for Windows authentication ASP.NET Windows身份验证+服务器始终获取匿名用户 - ASP.NET Windows Authentication + server always getting anonymous user ASP.NET身份-如何维护登录用户角色? - Asp.net identity - How to maintain logged in user role? Asp.net Identity:登录时更改用户角色 - Asp.net Identity: change user role while logged in ASP.NET Identity,无法访问当前登录的用户 - ASP.NET Identity, cannot access current logged in user ASP.NET身份无法识别登录用户是否已通过身份验证 - ASP.NET Identity not recognizing logged in user as authenticated ASP.NET身份编辑是否记录在用户的数据中? - ASP.NET Identity editing logged in user's data? ASP.NET身份记录用户注册和上次登录时间 - ASP.NET Identity record user registration and last logged on time Asp.Net Windows身份验证:是否可以不询问登录用户是否已经登录到活动目录? - Asp.Net windows authentication: is it possible not to ask login if user is already logged in active directory? ASP.NET身份+ Windows身份验证(混合模式 - 表单+ Windows) - ASP.NET Identity + Windows Authentication (Mix mode - Forms + Windows)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM