Get Windows login in ASP.NET website on IIS 7

Posted on 2011-10-06
Last Modified: 2013-11-05
In my 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
    LVL 18

    Expert Comment

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


    Author Comment

    i am already using this.
    LVL 14

    Accepted Solution

    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,

    Author Comment

    Yes, I already did this.
    LVL 14

    Assisted Solution

    by:Dustin Hopkins
    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

    I tried above solution.
    Still not working for me.

    Author Closing Comment

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

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
    Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now