2

I have a CMS driven website which has been working absolutely fine. We recently moved it from a Windows 2008 server to a Windows 2008 R2 server.

As far as I could tell the folder permissions were replicated correctly, but we have been finding that files added through the .net CMS are not inheriting the folder permissions.

I have even gone as far as setting the root of the websites folder EVERYONE permission to Full Control, but this doesnt appear to help either.

I have never previously had issues with this on the Windows 2008 server. So the only thing I can attribute it to is 2008 R2.

Any suggestions?

Update:

I have looked into this a little more, it seems saving the file from form post works, but when I move it from a staging folder to the live folder, it does not get the new folders permissions, in fact it even loses the permissions it had originally and it reduced down to:

System (full control), Network service (full control), Administrators (full control), IIS_Users (special)

Anthony Main
  • 6,039
  • 12
  • 64
  • 89
  • Unfortuantely I do not have access to the source code in this case to modify it – Anthony Main Apr 20 '12 at 13:03
  • What CMS is it? Custom? Did you try setting a web.config file with specific permissions in the folder you want to set these attributes to? – John Apr 20 '12 at 15:46
  • It is based upon Cuyahoga but I no longer have the source of the build. I havent set any web.config file permissions no, suggestions? – Anthony Main Apr 20 '12 at 15:58

1 Answers1

0

Have you looked at the FileAttributes method?

It's not tested, but something along the lines of this might work when you upload the file:

  FileAttributes attributes = File.GetAttributes(path);

  if ((attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
  {
      attributes = FileAttributes.Normal;

      File.SetAttributes(path, attributes);
  }
John
  • 1,268
  • 16
  • 25
  • This won't work. File attributes no not contain security information. Just flags for things like 'Read only', 'Hidden', etc. – Russell Horwood Nov 25 '14 at 12:06
  • I think you want: var fs = File.GetAccessControl(destination); fs.SetAccessRuleProtection(false, false); File.SetAccessControl(destination, fs); – Russell Horwood Nov 25 '14 at 13:01