iis6, iis7, iis7.5 : who is the user ?

Necuno

Court Jester
Joined
Sep 27, 2005
Messages
58,567
not really sure what to call this problem but what happens is that i want to know what nt account is accessing the page.

basically i use these 3 methods to test

1
Code:
SecurityIdentifier user = System.Security.Principal.WindowsIdentity.GetCurrent().User;

IdentityReference userName = user.Translate(typeof(System.Security.Principal.NTAccount));

2
Code:
HttpContext.Current.User.Identity.Name;

3
Code:
System.Environment.UserName

4
Code:
Page.User.Identity.Name

on box A with iis6
1) PRETORIA\jannie
2) PRETORIA\jannie
3) jannie
4) PRETORIA\jannie

on box B with iis6 or Box C with iis7.5
1) NT AUTHORITY\NETWORK SERVICE
2) PRETORIA\jannie
3) NETWORK SERVICE
4) PRETORIA\jannie

for the life of my i can't figure out why this is happening on B and C. its exact same webpage with exact same web.config.

all three are in .net 2 pool, with exactly same identity as network service.

all three's iis services also exactly the same long as.

all three are Integrated Windows authentication with basic authentication and no anonymous access allowed.

as far as i can tell box A has no impersonation setup at all, question is just why do A do what A do :confused::mad:
 
Last edited:

Johand

Expert Member
Joined
Jan 21, 2005
Messages
2,179
1 and 2 will return the usernames of the windows user currently executing the code. It IS NOT related to the web-page user.

My suspicion is that on Box A you have set IIS/ASP.NET to execute under your username. You can check that under the Administrative Tools in the Control Panel. I am pretty sure that it does not get the username from the webpage. You can check it out by visiting the webpage with another user.
 

Necuno

Court Jester
Joined
Sep 27, 2005
Messages
58,567
thanks ill go look and see whats up on monday or maybe tomorrow :)
 

guest2013-1

guest
Joined
Aug 22, 2003
Messages
19,800
Box B & C for 1 and 3 you're asking who is executing the code. And the "who" is the machine. Not the user.

Make sure you're logged in and don't have anonymous turned on. Also what Johand mentioned...
 
Top