Async and NTFS Permissions in Temp Directory

2 posts, 0 answers
  1. Robert
    Robert avatar
    2 posts
    Member since:
    May 2012

    Posted 12 Nov 2014 Link to this post

    I ran into an issue where an FTP user could not access files uploaded from a radasyncupload control.  The user had permissions to the target directory.  Files added to the directory inherited the permissions of the directory when except when uploaded asynchronously. 

    Here’s what I found.  In a part of my application I’m Telerik RadFileUpload instead of the standard asp file upload control. 

    Because Telerik RadFileupload is asynchronous, it first uploads the file to a temporary directory (/RadUploadTemp).  Once fully
    uploaded, it then automatically moves it to the target directory (/TargetDirectory/…)
     
    Here is the problem.  As the file is being moved it takes the permissions associated the temporary directory with it. Since the fpt account had no permissions in the RadUploadTemp directory, it assigns no permissions to the file when moved to the TargetDirectory .

    In order to resolve this, I gave read permissions the ftp account in the RadUploadTemp directory and now it copies the files with the permissions.

    While the link below does not address the rad control specifically, it lead me to the answer.  In my case, I had to apply permissions to the temp directory.

    http://stackoverflow.com/questions/23136723/why-are-permissions-wonky-when-my-iis-worker-saves-a-file-in-asp-net

    Is this something Tererik could fix in a way similarly stated in the article?:

    "I suspect the problem is with the use of Path.GetTempFileName followed by File.Move. When the uploaded file is saved to tempFilename, the temporary file gets whatever permissions are assigned to the temporary folder. Moving the file preserves those permissions as is instead of recalculating the inheritable permissions based on the destination.Instead of File.Move, try using File.Copy"

    Hope this helps somebody else. 



  2. Hristo Valyavicharski
    Admin
    Hristo Valyavicharski avatar
    975 posts

    Posted 17 Nov 2014 Link to this post

    Hi Robert,

    Thank you for sharing this with the community.

    You are right the RadAsyncUpload will move uploaded files on postback, but this can be changed. It is possible to read and save the file stream manually. Also you can change the Temporary Folder to a folder that your FTP user has permissions. AsyncUpload has a UseApplicationPoolImpersonation, which defines whether to use application pool impersonation.
    http://msdn.microsoft.com/en-us/library/134ec8tc%28v=vs.100%29.aspx

    The problem is confrontational and cannot resolve it.

    Regards,
    Hristo Valyavicharski
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top