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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:35:36+00:00 2026-05-14T16:35:36+00:00

Some Details I am working with VisualWebGUI, so this app is like ASP.NET, and

  • 0

Some Details

  • I am working with VisualWebGUI, so this app is like ASP.NET, and it is deployed on IIS 7 (for testing)
  • For my ‘Web Site’, Anonymous Authentication is set to a specific user (DomainName\DomainUser). In my web.config, I have impersonation on. This is how I got my app to access the share in the first place.

The Problem

There is a point in the the app where we use the Thread class, something similar to:

Thread myThread = new Thread(new ThreadStart(objInstance.PublicMethod));
myThread.Start();

What I have noticed is that I can write to my logs (text file on the share), everywhere throughout my code, except in the thread that I kicked off. I added some debugging output and what I see for users is:

  • The thread that’s kicked off: NT AUTHORITY\NETWORK SERVICE
  • Everywhere else in my code: DomainName\DomainUser (described in my IIS setup)

OK, for some reason the thread gets a different user (NETWORK SERVICE). Fine. But, my share (and the actual log file) was given ‘Full Control’ to the NETWORK SERVICE user (this share resides on a different server than the one that my app is running).

If NETWORK SERVICE has rights to this folder, why do I get access denied? Or is there a way to have the thread I kick off have the same user as the process?

  • 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-14T16:35:37+00:00Added an answer on May 14, 2026 at 4:35 pm

    You can also get the new thread to impersonate the user that issued the request. For example, if you are starting your request in the Page.Load event it might look like this.

      public partial class MyPage : System.Web.UI.Page
      { 
        protected void Page_Load(object sender, EventArgs e)
        {      
          Thread myThread = new Thread(new ParameterizedThreadStart(ThreadMethod));
          myThread.Start(HttpContext.Current.User); 
        }
    
        private void ThreadMethod(object state)
        {
          WindowsPrincipal principal = state as WindowsPrincipal;
    
          WindowsImpersonationContext impersonationContext = null;
          try
          {
            if (principal != null)
            {
              Thread.CurrentPrincipal = principal;
              impersonationContext = WindowsIdentity.Impersonate(((WindowsIdentity)principal.Identity).Token);
            }
    
            // Do your user specific stuff here...
          }
          finally
          {
            if (impersonationContext != null)
            {
              impersonationContext.Undo();
            }
          }
        }
      }
    

    You will notice I passed the Principal from the ASP.NET thread through to the new thread, I obviously assume that you are using Windows Integrated Authentication so I did not do much in the way of error checking, this is just a quick sample.

    Note: For VWG you would get the user from the VWG context and run the impersonation code in the appropriate function, this example is ASP.NET jsut because the environment is the same, just I do not know the VWG objects off the top of my head.

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

Sidebar

Related Questions

Some web applications, like Google Docs, store data generated by the users. Data that
I have made some code which exports some details of a journal article to
I read the SDK document, but can not understand some details, need some help.
Some WPF controls (like the Button ) seem to happily consume all the available
Some e-Marketing tools claim to choose which web page to display based on where
Some API returns me XmlCursor pointing on root of XML Document. I need to
Some things look strange to me: What is the distinction between 0.0.0.0, 127.0.0.1, and
Some Eclipse plugins are mandated by your environment. The appropriate source code management plugin,
Some programming languages such as Java and C# include encryption packages in their standard
Some files in our repository are individual to each developer. For example some developers

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.