Get Windows login in ASP.NET website on IIS 7

Posted on 2011-10-06
Medium Priority
Last Modified: 2013-11-05
In my asp.net 4.0 website I am using windows login  user name to login in my website without asking credential if that windows login user is  in DB if that user not in db then asking credential and authenticate against db .
To achieve above goal I implemented form and widows authentication in my website.
When I ran website through VS 2010(Dev. environment) I get actual windows login name but if I ran website on IIS 7 then I get “IUSER” as a windows login.
Following command I am trying  
"HttpContext.Current.Request.LogonUserIdentity.Name" get "IUSR" (NT AUTHORITY\IUSR) on IIS 7.
"HttpContext.Current.User.Identity.Name"  get  empty on IIS 7.
How can i get actual windows login on IIS 7 as well?
Question by:Barnum
  • 4
  • 2
LVL 18

Expert Comment

ID: 36926417
Hi! You need to enable impersonation in web.config:
    <identity impersonate="true"/>


Author Comment

ID: 36926589
i am already using this.
LVL 14

Accepted Solution

Dustin Hopkins earned 1500 total points
ID: 36928662
Have you enabled windows authentication for the site in IIS 7? You do this by clicking the authentication icon for your website/application's container in IIS manager. and enabling "windows authentication" and probably disable anonymous authentication.

Hope this helps,
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  


Author Comment

ID: 36932578
Yes, I already did this.
LVL 14

Assisted Solution

by:Dustin Hopkins
Dustin Hopkins earned 1500 total points
ID: 36932699
Ok to wrap this up, on the server you have:
Enabled Windows authentication
Disabled Anonymous Authentication
The server is on the same domain as the connecting computer

In your application:
Turn off Impersonation, unless you are actually using this.
And you have set the following in the web config:
<authentication mode="Windows" />
   <deny users="?"/>
The authorization section forces the client to authenticate.

After double checking this are you still getting a blank user instance?

Hope this helps,


Author Comment

ID: 36950784
I tried above solution.
Still not working for me.

Author Closing Comment

ID: 37002421
We settled on a different method of authentication.  Thanks for all the the help, though!

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Lync server 2013 or Skype for business Backup Service Error ID 4049 – After File Share Migration
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question