1 2 3 4 5 6 7 8 9 10 11 12
|
string user = "Administrateurs";
DirectoryInfo dInfo = new DirectoryInfo(FoldersView.SelectedNode.FullPath);
DirectorySecurity dSecurity = dInfo.GetAccessControl();
//DirectoryEntry user = new DirectoryEntry();
NTAccount acct = new NTAccount(user);
IdentityReference id = acct.Translate(typeof(SecurityIdentifier));
FileSystemAccessRule rule = new FileSystemAccessRule(id, FileSystemRights.ReadAndExecute | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow);
dSecurity.AddAccessRule(rule);
dInfo.SetAccessControl(dSecurity); |
Partager