简体   繁体   中英

ASP .NET - Get username on Windows Server 2003 (Terminal Service)?

On a intranet ASP .NET (C#) page I am trying to retrieve the current username.

From my local machine (Firefox 3.5) I can see results (from my local login) for the following possibilities:

<% Response.Write(User.Identity.Name); %>
<% Response.Write(HttpContext.Current.User.Identity.Name); %>
<% Response.Write(Page.User.Identity.Name); %>

However when I browse locally(IE8) or on the server (IE7) none of the above work for my terminal server login.

Is this a permission issue between IE and the webpage?

UPDATE1

Just tested the same page on the Terminal Server with Firefox portable and it also blocks the username.

Hmm couple of setting you could check:

1) Internet Options > Security > (Choose your Zone) > Custom level... > User Authentication > Logon > Automatic logon with current user name and password

and/or

2) Internet Options > Advanced > Enable Integrated Windows Authentication

IE - forgive me for the vagueness of this answer, I haven't used it in a long time: there's a setting in IE for enabling the passing of usernames. That may be off due to Group Policies.

Thinking out loud...

Firefox would normally not work if the site used native Windows security. So, is it using text-based logon (do you actually have to log on from within Firefox?)? That would explain Firefox working.

Local browsing/server browsing: Normal browsing (internal browsing) normally doesn't bounce off a proxy server. It may be the case where the TS is configured to know this and why credentials are being passed correctly (for example, can you browse through TS using IE - does it work? Same group policy settings apply.) I've seen installations where all traffic is pushed through a proxy server, then back to internal servers. Unfortunately, this tends to strip credentials and that may be happening here, too.

What will help are the IIS logs. Do you see the failed IE traffic (403'd, I think)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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