By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,089 Members | 1,952 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,089 IT Pros & Developers. It's quick & easy.

Inherented ACL's lost when adding a new ACE to a Share directory

P: 1
Hello
I've got a very strange Problem. When im adding a new ACE entry to a UNC Direcotry the inherented ACL's will be lost. When I'm adding a new ACE to a directory / file in this UNC path the inherented ACE are still available.

What's wrong ? I don't understand the difference between \\server\share and \\server\share\directory while adding a ACE

AndyL

Sample:
\\myserver\myshare
Inherited ACE: Administrators, Network Service

After adding a ACE:
\\myserver\myshare
Inherited ACE: <empty>
ACE: myUser

Sample II:
\\myserver\myshare
Inherited ACE: Administrators, Network Service

After adding a ACE:
\\myserver\myshare
Inherited ACE: Administrators, Network Service

ACE: myUser

here is my code:
Expand|Select|Wrap|Line Numbers
  1.     class programm
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             String dir1 = @"\\myserver\myshare";
  6.             String dir2 = @"\\myserver\myshare\test";
  7.             String usr = "myuser";
  8.             AddDirectorySecurity(dir1, usr , System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow);
  9.             Console.ReadKey();
  10.              AddDirectorySecurity(dir2, usr , System.Security.AccessControl.FileSystemRights.FullControl, System.Security.AccessControl.AccessControlType.Allow);           
  11.             Console.ReadKey();
  12.         }
  13.  
  14.         public static void AddDirectorySecurity(string FileName, string Account, FileSystemRights Rights, AccessControlType ControlType)
  15.         {
  16.             // Create a new DirectoryInfo object.
  17.             DirectoryInfo dInfo = new DirectoryInfo(FileName);
  18.  
  19.             // Get a DirectorySecurity object that represents the 
  20.             // current security settings.
  21.             DirectorySecurity dSecurity = dInfo.GetAccessControl();
  22.  
  23.             // Add the FileSystemAccessRule to the security settings. 
  24.             dSecurity.AddAccessRule(new FileSystemAccessRule(Account,
  25.                                                             Rights,
  26.                                                             ControlType));
  27.  
  28.             // Set the new access settings.
  29.             dInfo.SetAccessControl(dSecurity);
  30.  
  31.         }
  32. }
  33.  
Jun 20 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.