|
-
Dec 21st, 2009, 01:22 PM
#1
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.
-
Dec 21st, 2009, 02:13 PM
#2
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.
-
Dec 21st, 2009, 04:51 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|