Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

How can I allow a web part to create a file on a unc path? I have a location with ntfs permissions set to everyone\full control and am getting 'access denied' messages.

The SP2010 app pool is running as a domain account, so on that basis alone, it should work. I can set the trust level of the SP web application to full, but that seems excessive for this one task. I would prefer not to have to go to the trouble of making an out-of-process web service to get around this.

What is the correct way to handle this?

Update: Still fails with trust set to 'full'.

share|improve this question
    
what are you writing to the file system and do you need to track who wrote it...i.e. does the write have to happen in the context of the currently logged in user? –  Rob D'Oria Aug 23 '11 at 14:34
    
No, It doesn't need to relate to the user at all. –  Jeff Sacksteder Aug 23 '11 at 15:16

1 Answer 1

up vote 3 down vote accepted

Is the UNC path location you're writing to in the same domain as the SharePoint server(s)?

If so, then I would just grant access to the app pool service account only and run your filesystem write code block with elevated privileges: SPSecurity.RunWithElevatedPrivileges

If not, then you will probably need to login as and impersonate an account within the domain hosting the UNC path location and run your filesystem write code block within the context of that account.

Either way, it's always preferable to store the content/data in a SharePoint list/library and not cross that architectural boundary if possible, but I won't harp on that too much since I can envision scenarios where that might not work (i.e. dropping a file for a mainframe batch process).

share|improve this answer
    
Yes, same domain. Your speculation regarding the batch process is not far off. This is an app operating on an external datatype and producing a file on a share. Only the UI is in Sharepoint. It doesn't really relate to any other Sharepoint content. In general, I would agree. –  Jeff Sacksteder Aug 23 '11 at 15:48
    
In that case, try running the operation with elevated privileges and granting the app pool account for that web app explicit privileges to the UNC path location...should work. –  Rob D'Oria Aug 23 '11 at 15:50
    
I don't get how that is able to elevate beyond the WSS Minimal trust setting on the the AppPool, but working nonetheless! –  Jeff Sacksteder Aug 23 '11 at 17:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.