2012-03-06 74 views
2

(這可能是更適合ServerFault - 如果是這樣,請遷移吧!)編程方式創建的文件並不總是繼承父文件夾的權限

我們最近升級從Windows 2003到Windows 2008的服務器上我們有現在已經得到報告說,某些動態生成的PDF文件正在給出「訪問被拒絕」的信息。我已驗證該文件夾對正在使用的用戶組具有「完全控制」,但似乎間歇性地創建文件時不會繼承父權限。

例如,父文件夾被稱爲Paperwork。 「用戶」組設置爲完全控制該目錄中的所有文件和子文件夾。這在95%的時間內工作。不過,偶爾會創建一個文件,當我查看該文件的安全權限時,「用戶」組而不是擁有完全控制訪問權限。

Windows Server 2008中是否存在需要更改的編程方式,或者這是服務器本身的配置問題?

回答

1

看看這個

enter image description here

試試這個:

private DirectorySecurity GetDirectorySecurity(string owner) 
    { 
     const string LOG_SOURCE = "GetDirectorySecurity"; 
     DirectorySecurity ds = new DirectorySecurity(); 

     System.Security.Principal.NTAccount ownerAccount = 
      new System.Security.Principal.NTAccount(owner); 

     ds.SetOwner(ownerAccount); 

     ds.AddAccessRule(
      new FileSystemAccessRule(owner, 
      FileSystemRights.FullControl, 
      InheritanceFlags.ObjectInherit, 
      PropagationFlags.InheritOnly, 
      AccessControlType.Allow)); 

     //AdminUsers is a List<string> that contains a list from configuration 
     // That represents the admins who should be allowed 
     foreach (string adminUser in AdminUsers) 
     { 
      ds.AddAccessRule(
       new FileSystemAccessRule(adminUser, 
       FileSystemRights.FullControl, 
       InheritanceFlags.ObjectInherit, 
       PropagationFlags.InheritOnly, 
       AccessControlType.Allow)); 
     } 
     return ds; 
    } 

裁判: File permissions do not inherit directory permissions

+0

威爾傳播到新創建的,目前不在目錄對象?我的意思是創建所有未來的文件。 – 2012-03-06 20:25:33