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 4257862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T05:34:16+00:00 2026-05-21T05:34:16+00:00

I have the following scenario where I’m planning in using windows authentication. 1.1) I

  • 0

I have the following scenario where I’m planning in using windows authentication.

1.1) I have a web server which will run within a domain.
1.2) The web site will run under the credentials of a domain user with a set of configured permissions (One which will be allowed access to the file system, SQL server database etc).
1.3) Users visiting the web site will belong to the same domain, so I’m planning in using windows authentication.

So at this point, an authenticated user, would access the site, but I guess that from code, “CurrentUser” would be the one under which the site is running.

I’d like the following.

2.1) To authenticate the user accessing the site with windows authentication. (Domain controller would be responsible for this).
2.2) For the site to run under the configured user from step 1.2. So it would have all of its permissions.
2.3) But I’d like to know the initial user used to authenticate from (step 2.1).

This way I could do the following:

3.1) User “A” decides to access the site, as he belongs to the same domain as the web server, he authenticates successfully.
3.2) From code I detect that “A” authenticated, so I’ll go and fetch his roles. “Role1, Role2, Role3”.
3.3) I then want the code to run under the user configured in step 1.2, but I’ll assign the Principal all of the roles retrieved from 3.2.

I’ve thought that maybe I could use Impersonation for this.

4.1) So user “A” decides to access the site and authenticates.
4.2) The site would initially run with “A” credentials, so the “CurrentUser” would be “A”.
4.3) Switch the user (somehow) back to the one from 1.2
4.4) I could retrieve all of 4.1 configured Roles.
4.5) Assign the Current Principal the roles retrieved from 4.4.

So in the end the web site will use Windows Authentication with Impersonation, but from code I’d switch back to user 1.2.

If you’ve reached this point thanks for reading! I’d like to know if this is possible and if it seems achievable or if I’m overcomplicating things.

Also suggestions in how can I plug into and where to do all the role retrieving and user switching.
Many thanks!

UPDATE 1

@ Code Jammr , you’re right, no need to do any crazy stuff. But I think I still need to look into HttpModules,..

After doing a few tests, searching etc…

I’ve started to understand the difference between these IIdentity objects:

HttpContext.Current.User.Identity
Thread.CurrentPrincipal.Identity
WindowsIdentity i2 = WindowsIdentity.GetCurrent();

I posted another question to help me understand them:
Help understanding impersonation

I think this answers my question.

  • 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-21T05:34:16+00:00Added an answer on May 21, 2026 at 5:34 am

    There are several code samples out there for doing Impersonation. Most involve dealing with tokens and Win API calls. But if you really must do it this way, I say this not knowing what your webserver type is. IIS 6 or IIS7, then there are many code samples out there to guide you along.

    Here is one link for ya that pretty much gives you a starting point.
    http://msdn.microsoft.com/en-us/library/aa331755(v=vs.71).aspx

    Here is a link on AD authentication and you may not have to do anything crazy.
    http://support.microsoft.com/kb/326340

    You may want to look into asp.net impersonation, app pool settings, etc… to see if there is a better way.

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

Sidebar

Related Questions

I have the following scenario. I'm working with a server which has a lib
I am trying to understand isolation/locks in SQL Server. I have following scenario in
I have the following scenario. I have created an ASP.NET web application (framework 3.5)
I have following Scenario: PHP(Server, Writer) ----> MySQL Database <------ PHP(Client, Reader/ Writer); PHPS
I have the following scenario. We have a sharepoint 2010 web template to create
I have following scenario: alt text http://static.zooomr.com/images/7579022_e64808b855_o.png We have a WebService which poses as
I have the following scenario: I have a content type called 'Product' in which
I have the following scenario: 1 List which contains the months of the year:
I have following scenario: The Android clients communicate with a PHP server via HTTP
I have following scenario Then I have function which checks following condition: var callback

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.