Results 1 to 3 of 3

Thread: ASP.NET/IIS - run in different user context

  1. #1

    Thread Starter
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    ASP.NET/IIS - run in different user context

    Is there a way to have one piece of code run under a different user account than the ASP.NET user account on a system?

    I have a need to grab a listing of files, and the ASPNET account doesn't have access to the folders where these files are. Another user account does, and I would like to use that account of possible. I don't do much web development, so I don't know exactly what my options are for doing this.

    I could create a shim app that runs under the required credentials and creates a temp file that the ASPNET account could read, but that creates more complexity than I would like, unless this is my only option.

    Granting the ASPNET account access to the folders could possibly be an option (I only need read access for this) but I figured that should be a last resort. I also don't even know if it will work since these folders are actually a windows home server JBOD share, not your typical file folder.

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: ASP.NET/IIS - run in different user context

    Yes, there's a way. Have a look at this KB article

    http://support.microsoft.com/kb/306158

    Scroll down to where it says "Impersonate a Specific User in Code". You'll have to use the Win32 APIs for this.

  3. #3
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: ASP.NET/IIS - run in different user context

    Hey,

    Another option would be to change the identity of the application pool running your application:

    http://msdn.microsoft.com/en-us/library/ms998297.aspx

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width