Click here to Skip to main content
16,022,413 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.
In my app on local network, any user should create a directory on shared folder using this code. test1 is the name of one of the user's folder for example.
DirectoryInfo di = new DirectoryInfo(@"\\Server\Test\test1"); DirectorySecurity ds=new DirectorySecurity(); ds.SetAccessRule(new FileSystemAccessRule(Enviroment.Username,FileSystemRights.FullControl, AccessControlType.Deny));  di.Create(ds);

Now when the admin in domain wants to read every directory from any user this error ocurred:

Attempted to perform an unauthorized operation.
The code that the admin runs is:
DirectoryInfo di = new DirectoryInfo(@"\\Server\Test\test1"); DirectorySecurity ds=new DirectorySecurity(); ds.SetAccessRule(new FileSystemAccessRule(Enviroment.Username, FileSystemRights.FullControl, AccessControlType.Allow));  di.SetAccessControl(ds); 


Where is my mistake?
Thanks in advance.
Posted
Updated 10-May-11 2:18am
v3

I suggest you go back and read up on NTFS security and how permissions work and permission inheritance. The code you have suggests a misunderstanding of how security works.

If security is properly configured on the root folder, your users shouldn't even have to set ACL's on any folders.
 
Share this answer
 
all the user can access and create the folder on the "Test" folder.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900