Impersonation and Path.GetTempPath()

O

Oleg Ogurok

Hi all,

I have a ASP.NET app that uses Excel interop to save an .xls file on disk in
a temp folder and then read it back and e-mails it as an attachment.

The problem is deciding where to store the temp file. My web.config has
<identity impersonate="true" />


When I call System.IO.Path.GetTempPath(), it returns
C:\DOCUME~1\MYSERVER\ASPNET\LOCALS~1\Temp. However, when I try to save the
file, I get an error saying "Microsoft Office Excel cannot access the file."
It seems despite the impersonation, I still get the home dir of ASPNET user
instead of the user under which the IIS virtual directory is running. Is
there a more correct way of getting a temp path?

Thanks.

-Oleg.
 
B

bruce barker

impersonation only changes the thread's credentials, not the profile
associated with the process. a user profile is where temp, default printer,
etc settings are stored. in fact asp.net usually runs without a profile.

-- bruce (sqlwork.com)
 
P

Phil Wilson

This is what the LoadUserProfile Win32 API is for - don't know if there's a
framework equivalent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Newbie question about impersonation 5
Impersonation 0
impersonation 3
Impersonation 1
asp.net impersonation limits? 0
Impersonation 4
Impersonation 0
Impersonation and Session_End() 1

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top