We help IT Professionals succeed at work.

Why file will not upload to folder on virtual directories?

kitesurf
kitesurf asked
on
Error: Access to the path 'C:\Inetpub\wwwroot\wss\VirtualDirectories\80\Upload\SharePoint Lessons Learned.docx' is denied.

I have a custom web part that uploads files to the above path with the above error only when not a farm administrator on SharePoint. Why?  I have a stand alone production server that works fine, but on a 2003 server 32 bit on vmware, it does not. Everything looks the same, except on production server we used multiple system accounts where on development single setup account.  Could that make a difference?
<appSettings>
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=..." />
    <add key="ConnString" value="Data Source=...;Initial Catalog=...;Integrated Security=SSPI;" />
    <add key="ServerName" value="http://..." />
    <add key="filefolder" value="C:\Inetpub\wwwroot\wss\VirtualDirectories\" />
    <add key="Port" value="80" />
    <add key="DirName" value="Upload" />
    <add key="Admin" value="..." />
    <add key="SessionTimeOut" value="20" />
    <add key="FeedCacheTime" value="300" />
    <add key="FeedPageUrl" value="/_layouts/feed.aspx?" />
    <add key="FeedXsl1" value="/Style Library/Xsl Style Sheets/Rss.xsl" />
    <add key="ReportViewerMessages" value="Microsoft.SharePoint.Portal.Analytics.UI.ReportViewerMessages, Microsoft.SharePoint.Portal, Version=12.0.0.0, Culture=neutral, PublicKeyToken=..." />
  </appSettings>

Open in new window

Comment
Watch Question

Ted BouskillSenior Software Developer
Top Expert 2009

Commented:
Why would you upload files onto the physical file system?  Sharepoint was designed to quickly add/remove servers on the farm that is why all the content is stored in content databases.

Maybe there is a different way to achieve your goals.

Author

Commented:
need a fix for this before we can change code.  
Ted BouskillSenior Software Developer
Top Expert 2009

Commented:
I don't understand your last comment in reference to the question.

Author

Commented:
it's not my web part to change, unless we conclude there lies the problem.
Senior Software Developer
Top Expert 2009
Commented:
Well there is a problem.  It's not the right way to work with Sharepoint.  Consider this because Sharepoint supports WebDAV this is perfectly valid.
http://sharepoint.domain.com/Documents/
or
\\sharepoint.domain.com\Documents\

Also there are free web parts (with source code) like this that upload directly to Sharepoint properly: http://spupload.codeplex.com/

So with options like that why would someone upload to the file system when Sharepoint doesn't support it?  I think it's because the web part developer understood ASP.NET but didn't understand Sharepoint and basically created a hack solution.

Any files uploaded to the file system will not be included in Sharepoint backups and will not be searched by the Sharepoint search engine.

If you hired someone to build the web part, ask them why they didn't do it the Sharepoint way.

Author

Commented:
can you tell me how to impersonate a sharepoint farm administrator only for the duration of the code?  I'm pretty sure they used run with elevated privileges, so we need something to accomplish this, and we will be done.  I really do appreciate your help.