I'm using the new System.Security.AccessControl stuff in 2.0.
This is a snippet typical of what I've done (sets Read access for Network Service on 'MyFolder')
SecurityIdentifier siNetworkService = new SecurityIdentifier(WellKnownSidType.NetworkServiceSid, null); NTAccount ntaNetworkService = siNetworkService.Translate(typeof(NTAccount)) as NTAccount; DirectoryInfo diMyFolder = new DirectoryInfo(myFolder); DirectorySecurity dsMyFolder = diMyFolder.GetAccessControl(); FileSystemAccessRule fsarNetworkService = new FileSystemAccessRule(ntaNetworkService, FileSystemRights.Read, AccessControlType.Allow); // I can't figure out why I need two ACEs for this, but I can't get the diMyFolder.SetAccessControl(dsMyFolder); |
Any idea why that 2nd ACE is required Is there a way to set this ACL with fewer lines of code I have about a dozen rules like this, and it adds up to about 100 lines of code.
- Mark

NTFS ACLs from C# (Whidbey)
Rocinante8
Hi Mark,
Sorry for the delay in responding to you. I haven't run into this issue with our testing for specific user accounts. Is this still affecting you If so, I'll take a closer look at this.
Thanks
Lakshan Fernando
BCL Team