0
votes

When I RDP to the web server (customer) I enter my user name as domain/username. Which tells me that I am in the AD. I set the web.config authentication mode="Windows" and Authorization deny="?" (my understanding is that this means deny all who are not authenticated by Windows.) Then I am trying to open a test page (test.aspx). And I get Access Denied. If I set the Authorization to allow users="*", the page opens. But the environment.UserDomainName returns "IIS APPPOOL". And I would like to see that the environment.UserDomainName would return actual domain name. What do I need to do? Or what am I missing?

1
I can't seem to get the current user name. I can get the domain name. I get the domain name as follows (works): Environment.UserDomainName; But when I try to get the user name (all methods below), I get the server name instead of the user name: Environment.UserName; System.Environment.UserName; Environment.GetEnvironmentVariable("USERNAME"); The web.config has: <authentication mode="Windows" /> <identity impersonate="true" /> or "false", make no difference. The site in IIS has Windows Authentication and Anonymous Authentication set to Enable.Hidalgo

1 Answers

0
votes

If I am understanding your question, you are trying to get the current user. If so you can use something like this:

string userName = System.Security.Principal.WindowsIdentity.GetCurrent().Name;