Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 919901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:37:15+00:00 2026-05-15T18:37:15+00:00

Here’s a simple question I’ve been stuck on for a while. When I set

  • 0

Here’s a simple question I’ve been stuck on for a while.

When I set < identity impersonate=true > in my web.config so that asp.net impersonates the logged on user automatically (or the anonymous account if not using Windows Authentication), where does the identity that asp.net impersonates come from?

This document: http://msdn.microsoft.com/en-us/library/ff649264.aspx shows three places you can retrieve information about the logged on user:

  • Httpcontext.Current.user
  • System.Threading.Thread.Current
  • System.Security.Principal.WindowsIdentity.GetCurrent
  • It seems that none of these locations consistently match the identity that gets impersonated when I set < identity impersonate=true > in web.config.

    I would like to know where the impersonated identity comes from.

    Specifically, I mean to ask at a low level, where exactly does the identity get retrieved from at run-time. I am familiar with the configuration of IIS, but I want to know how the identity is retrieved at run-time and where it comes from. For the sake of discussion, let’s suppose that the identity is set in IIS, not in the web.config file.

    • 1 1 Answer
    • 0 Views
    • 0 Followers
    • 0
    Share
    • Facebook
    • Report

    Leave an answer
    Cancel reply

    You must login to add an answer.

    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. Editorial Team
      Editorial Team
      2026-05-15T18:37:16+00:00Added an answer on May 15, 2026 at 6:37 pm

      You cannot separate the impersonation-part from the authentication-part. I think you know that since you write

      … asp.net impersonates the logged on user automatically (or the anonymous account if not using Windows Authentication)…

      But I am confused by the sentence

      For the sake of discussion, let’s suppose that the identity is set in IIS, not in the web.config file.

      What exactly do you mean by this?

      But let me have a shot at an answer anyway:
      Let’s assume you are using IntegratedWindowsSecurity, <identity impersonate=true> and <authentication mode=Forms> in Web.config. This would correspond to the second-last row of the last table in Building Secure ASP.NET Applications: Authentication, Authorization, and Secure Communication which you cited.

      It states that Domain\UserName will be returned from WindowsIdentity in this case. And I assume you are wondering where that Domain\UserName-Identity comes from… There are some restrictions on using Kerberos like IE has to classify the URL as “Intranet” or “Local” but I think this is not important here.

      Now it is important to distinguish between setting <authentication mode=windows> in Web.config and setting the access mode to IntegratedWindowsSecurity (or whatever it is called) in IIS. Being in the last table of aforementioned link we are in the situation of IIS being set to IntegratedWindowsSecurity (nevertheless we can set <authentication mode="windows"> in Web.config!). So IE negotiates with IIS on how to authenticate the currently logged in user. Either using NTLM or Kerberos (mainly depending on the Windows version). That is where the Domain\UserName comes from.

      The following article (talking about delegation, I know) might shed more light on the issue ASP.NET Delegation:

      Integrated Windows Authentication

      When Internet Explorer attempts to
      access a protected resource, IIS sends
      two WWW-Authenticate headers to the
      browser, Negotiate and NTLM. The
      Negotiate header is only sent by IIS
      running on Windows 2000 or later. This
      header indicates that IIS supports the
      Negotiate protocol, which enables a
      negotiation to occur between Internet
      Explorer and IIS on whether to use
      Kerberos or NTLM authentication. IIS
      uses Kerberos if both the client
      (Internet Explorer 5.0 and later) and
      server (IIS 5.0 and later) are running
      Windows 2000 or later, and both are
      members of the same domain or trusted
      domains. Otherwise, the server
      defaults to using NTLM.

      Since NTLM authenticates the user for
      IIS without providing the user’s
      credentials to IIS, IIS cannot
      delegate that user’s credentials to a
      remote machine.

      When used in conjunction with Kerberos
      v5 authentication, IIS can delegate
      security credentials among computers
      running Windows 2000 or later that are
      trusted and configured for delegation.

      You probably know these links but I am posting them anyway:

      • ASP.NET Impersonation
      • ASP.NET Process Identity

      EDIT:
      To be a bit more precise I think (not sure here) that IIS creates the WindowsIdentity from a LogonToken (the one you get by calling unmanaged Win32 LogonUser function) using the constructor explained here in msdn. Also the example code in the documentation of the WindowsIdentity Class is quite interesting (IntPtrStringTypeConstructor for example). The logon token would have to come from IE then.

      Scott Hanselman wrote about a similar thing also: System.Threading.Thread.CurrentPrincipal vs. System.Web.HttpContext.Current.User or why FormsAuthentication can be subtle.

      And I think you might be able to extract additional information if you look for solutions to “implant” a custom principal object into ASP.NET authentication process (usually using Application_AuthenticateRequest in Global.asax). Like Using Custom Principal with Forms Authentication in ASP.NET for example.

      Or you can use Reflector and see for yourself 🙂

      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    Here a simple question : What do you think of code which use try
    Here is my question. I am having this simple menu. <div id=menu> <ul> <li>
    That's pretty much it. I'm using Nokogiri to scrape a web page what has
    Here's what I'm trying to accomplish with this program: a recursive method that checks
    Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
    here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
    Here is the problem that I am trying to solve. I have two folders
    Here is my program to find all the subsets of given set. To solve
    Here's a query that works fine: SELECT rowid as msg_rowid, a, b, c FROM
    Here is my code (Say we have a single button on the page that

    Explore

    • Home
    • Add group
    • Groups page
    • Communities
    • Questions
      • New Questions
      • Trending Questions
      • Must read Questions
      • Hot Questions
    • Polls
    • Tags
    • Badges
    • Users
    • Help
    • SEARCH

    Footer

    © 2021 The Archive Base. All Rights Reserved
    With Love by The Archive Base

    Insert/edit link

    Enter the destination URL

    Or link to existing content

      No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.