Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

.docx file just created via web app cannot be opened

$
0
0

.NET 4, c#

The app creates a file using:  

FileStream fileStream = new FileStream(documentPath, System.IO.FileMode.Create)

And fetches the file using:

MemoryStream mem = new MemoryStream();
byte[] byteInfo = File.ReadAllBytes(documentName);

This has been working for years, except for recently some of the files cannot be opened.  

The problem files are owned by "ASP.NET v4.0", but not all ASP.NET v4.0 owned files have this problem.  I checked permissions, and for the ones that had the problem, there was a permissions entry for user "ASP.NET v4.0" for which the only permissions checked were Special Permissions, both the "allow" and "deny" boxes were checked.  The file also has user "NULL SID" listed with Special Permissions "deny" only, and also has an Everyone user listed with Special Permission "allow".

Since I was not the ASP.NET v4.0 user I could not remove these permissions to see if that would have an effect, but by changing file ownership to "Administrators" the problem for this file was solved.

Don't know if is relevant, but when I look at the files from a Cygwin bash shell, "ls -l" shows permissions 070, and both user and group ownership are "ASP.NET v4.0".  But again there are many files like this that don't have the problem.

We seem to be able to reproduce this rather consistently, i.e. use the app to create a .docx file, then find out that the file cannot be opened with the app until I "fix" it by either copying the file back and forth (which implicitly changes it's permission) or explicitly changing the ownership.

We are running:

  • Server2008
  • IIS 7.0
  • Application pool used by this site is ASP.NET v4.0, pool is defined as v4.0/Integrated, ApplicationPoolIdentity
  • Site is set up with pass-through authentication
  • Application pool defaults for the server is set to identity NetworkService

===

So I am trying to figure out what's going on, is it a folder permissions setting somewhere, or one of the IIS settings, or a Windows user setting?  Assuming that the iis worker is running as user ASP.NET v4.0, then when it creates a file it is setting some permissions that don't allow it to reopen the file.  I can always open the file from Windows Explorer, just not from the web app until the file is "fixed".

Any help would be much appreciated!

Thanks.  John


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>