Esempio n. 1
0
        public static List<Folder> GetListOfFolders(string file)
        {
            List<Folder> listeFolders = new List<Folder>();
            try
            {
                StreamReader sr = new StreamReader(file, Encoding.UTF8);
                string line = sr.ReadLine();

                while (line != null)
                {
                    Folder folder = new Folder();
                    folder.Name = line;
                    folder.CreateContent = true;
                    folder.State = "En attente";
                    folder.StatePerso =   "Personnel : En attente";
                    folder.StatePrivate = "Private : En attente";
                    folder.StatePublic =  "Public : En attente";

                    listeFolders.Add(folder);
                    line = sr.ReadLine();
                }
                sr.Close();

                return listeFolders;
            }
            catch
            {
                return new List<Folder>();
            }
        }
Esempio n. 2
0
        private void CreatePublic(string publicFolder, Folder folder)
        {
            // Create the new public directory
            Directory.CreateDirectory(publicFolder);

            // Get the directory for checkings
            DirectoryInfo info = new DirectoryInfo(publicFolder);
            DirectorySecurity dirSecurity = info.GetAccessControl();
            dirSecurity.SetAccessRuleProtection(false, false);

            // Get the rules for the directory and suppress them
            AuthorizationRuleCollection rules = dirSecurity.GetAccessRules(true, true, typeof(NTAccount));
            foreach (AuthorizationRule rule in rules)
            {
                if (rule is FileSystemAccessRule)
                {
                    dirSecurity.RemoveAccessRule((FileSystemAccessRule)rule);
                }
            }

            //Create the new rules for the directory
            dirSecurity.AddAccessRule(new FileSystemAccessRule(@"ad\fbm-" + departement + "-g", FileSystemRights.FullControl & ~FileSystemRights.DeleteSubdirectoriesAndFiles & ~FileSystemRights.TakeOwnership & ~FileSystemRights.ChangePermissions, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            dirSecurity.AddAccessRule(new FileSystemAccessRule(@"ad\fbm-" + departement + "-admin-acl-g", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            dirSecurity.AddAccessRule(new FileSystemAccessRule(@"ad\Domain Admins", FileSystemRights.FullControl, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            Directory.SetAccessControl(publicFolder, dirSecurity);
        }