September 14th, 2012, 09:42 AM
C# & IIS 7 - issue reading correct registry key when using impersonate
I posted here, but don't know if the issue is related to IIS7 or my code.
I have created a IIS7 SOAP Web application which does not read the correct values from the registry. I read the registry using following code:
The path is used to read the output from a PDF printer.
key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\path\\to\\key");
string tempPath = (string)key.GetValue("tempPath");
The application is configured with impersonate as a specific user with local administrator rights, e.g. domain_user1.
When I call the service from my client PC, the service want to use the system temp folder: C:\Windows\temp, instead of the value from registry (D:\temp)
if I log in with domain_user1 to the system using remote desktop, then it does give the correct value.
For my web application I have also
- enabled anonymous access using IUSR.
- set Domain_user1 in connec to.
- created a new application pool with Domain_user1 as identity.
- with with load user folder for the application pool.
It looks like it is reading %temp% from somewhere.
The reason I changed the path away from the standard temp folder is that the service and/or the printer have issues with accessing it, even if "everyone" has full permission.
Could not find any solution on Google, most of what i found told that adding a impersonate will be the solution. :confused:
Any one who ever had this issue?
Last edited by MrFujin; September 14th, 2012 at 09:52 AM.
September 14th, 2012, 06:33 PM
I decided to have the information into the configuration file too, but am still interested in any comments that can explain why I got this behaviour/issue.
Currently, I now try to call the excel printEx function where it return with "no printers are installed", even though I can go through PrinterSettings, find the correct printer and set it as default printer.