UnauthorizedAccessException with XslCompiledTransform.Load
-
Tuesday, May 15, 2012 5:12 PM
I have written a WCF service that takes an XML string from our client, adds the appropriate directives to it, converts it to an XmlDocument, and saves it to the appropriate folder. Once the load is complete, I check to make sure that the file is in the correct format by loading its stylesheet, doing a quick transformation, and then deleting the resulting html file. The stylesheet is located on a different server than the XML document, so the permissions on the folders are not the same. When I run the service through IIS with myself as the Identity for the ApplicationPool, it runs just fine. However, when I use our service 'user', I end up with an UnauthorizedAccessException on the XslCompiledTransform.Load(). The only difference is the credentials in the ApplicationPool in IIS, so it is clearly a permissions issue. I have given the service 'user' account full control on the stylesheet and then on the folder that contains the stylesheet. Obviously, this is NOT what I want to do.
Is there a way to handle the Load while forcing some set up permissions on the file in code? I have tried using an XmlUrlResolver, but I have the same error whether I use DefaultCredentials or DefaultNetworkCredentials for the resolver's Credentials. I have also not found any code that was helpful in determining what to do with the resolver other than set the Credentials and use it as a parameter in the Load. I added XsltSettings.TrustedXslt, but that made no difference either. The stylesheet itself is very simple (I wrote it, so I know I am not missing anything hidden in there).
Thanks for your help in advance!
Christine A. Piffat
- Moved by Bob ShenMicrosoft Contingent Staff Thursday, May 17, 2012 3:55 AM (From:Visual C# General)
All Replies
-
Thursday, May 17, 2012 3:54 AM
Hi Christy,
According to your description, I'd like to move this thread to XML, System.Xml, MSXML and XmlLite Forum for better support, where more experts live.
Thanks for your understanding.Bob Shen [MSFT]
MSDN Community Support | Feedback to us
-
Friday, May 18, 2012 4:00 PM
Thanks! Any suggestions on what permissions are required for the Load method of XslCompiledTransform? Also, is there any way to grant these permissions temporarily?
Thanks in advance!
Christine A. Piffat

