开发者

ASP.Net Windows Authentication - User Identity Logged Into Server

开发者 https://www.devze.com 2023-03-21 08:38 出处:网络
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.When I deploy to my test web ser

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. 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. What gives?

UPDATE: I am using Windows XP SP3 with the development IIS server (not IIS, even though IIS is installed). I created a new test site (empty web template from VWD2010 Express). Only configuration I did so far was on the Default.aspx page, I added:

<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. 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. The user returne开发者_JS百科d 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. 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. If fixing that fails, then make sure you have not hotwired the service in IIS to use a specific account.


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. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号