// Constructors
 public PropertySetAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type, PropertyAccess access, System.Guid propertySetType)
 {
 }
 // Constructors
 public EventWaitHandleAccessRule(System.Security.Principal.IdentityReference identity, EventWaitHandleRights eventRights, AccessControlType type)
 {
 }
 public override System.Security.AccessControl.AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags)
 {
     throw null;
 }
Example #4
0
 public RegistryAuditRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.RegistryRights registryRights, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AuditFlags))
 {
 }
Example #5
0
 public ExtendedRightAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type, System.Guid extendedRightType)
 {
 }
Example #6
0
 public override System.Security.AccessControl.AccessRule AccessRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AccessControlType type)
 {
     return(default(System.Security.AccessControl.AccessRule));
 }
 public override AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags)
 {
     throw new NotImplementedException();
 }
Example #8
0
        static void ChangeOwner(DirectoryInfo dirInfo, System.Security.Principal.IdentityReference currentOwnerId, System.Security.Principal.IdentityReference newOwnerId)
        {
            CheckAttributes(dirInfo);
            if ((dirInfo.Attributes & FileAttributes.ReparsePoint) != 0)
            {
                // Ignore reparse points

                return;
            }
            try {
                DirectorySecurity dirSec = dirInfo.GetAccessControl();
                if (dirSec.GetOwner(typeof(System.Security.Principal.SecurityIdentifier)) == currentOwnerId)
                {
                    ++sNumChanged;
                    if (!sDryRun)
                    {
                        dirSec.SetOwner(newOwnerId);
                        dirInfo.SetAccessControl(dirSec);
                    }
                    Console.WriteLine("Set ownership on directory '{0}' to '{1}'", dirInfo.FullName, newOwnerId.ToString());
                }
            } catch (Exception exception) {
                Console.WriteLine("Exception processing file '{0}': '{1}'", dirInfo.FullName, exception.Message);
            }
        }
 public void SetGroup(System.Security.Principal.IdentityReference identity)
 {
 }
Example #10
0
        static void Main(string[] args)
        {
            string root         = "";
            string newOwner     = "";
            string currentOwner = "";

            for (uint argIndex = 0; argIndex < args.Length; ++argIndex)
            {
                string op = args[argIndex];
                switch (op)
                {
                case "--root": {
                    ++argIndex;
                    if (argIndex < args.Length)
                    {
                        root = args[argIndex];
                    }
                    else
                    {
                        PrintUsage();
                        return;
                    }
                    break;
                }

                case "--to": {
                    ++argIndex;
                    if (argIndex < args.Length)
                    {
                        newOwner = args[argIndex];
                    }
                    else
                    {
                        PrintUsage();
                        return;
                    }
                    break;
                }

                case "--from": {
                    ++argIndex;
                    if (argIndex < args.Length)
                    {
                        currentOwner = args[argIndex];
                    }
                    else
                    {
                        PrintUsage();
                        return;
                    }
                    break;
                }

                case "--dry-run": {
                    sDryRun = true;
                    break;
                }

                default: {
                    Console.WriteLine("Unknown option '{0}'", op);
                    PrintUsage();
                    break;
                }
                }
            }

            if (root == "" || newOwner == "")
            {
                PrintUsage();
                return;
            }

            // Parse owner strings
            string SIDPattern = @"^S-\d-\d+-(\d+-){1,14}\d+$";

            System.Security.Principal.IdentityReference currentOwnerId = null;
            if (currentOwner != "")
            {
                if (Regex.IsMatch(currentOwner, SIDPattern))
                {
                    Console.WriteLine("Current owner '{0}' is a SID", currentOwner);
                    currentOwnerId = new System.Security.Principal.SecurityIdentifier(currentOwner);
                }
                else
                {
                    Console.WriteLine("Current owner '{0}' is an NT Account", currentOwner);
                    currentOwnerId = new System.Security.Principal.NTAccount(currentOwner);
                }
            }

            System.Security.Principal.IdentityReference newOwnerId;
            if (Regex.IsMatch(newOwner, SIDPattern))
            {
                Console.WriteLine("New owner '{0}' is a SID", newOwner);
                newOwnerId = new System.Security.Principal.SecurityIdentifier(newOwner);
            }
            else
            {
                Console.WriteLine("New owner '{0}' is an NT Account", newOwner);
                newOwnerId = new System.Security.Principal.NTAccount(newOwner);
            }
            Console.WriteLine();
            Console.WriteLine();

            uint          numDirsToProcess  = 0;
            uint          numDirsProcessed  = 0;
            uint          numFilesProcessed = 0;
            uint          numReparsePoints  = 0;
            DirectoryInfo rootDir           = null;

            try {
                rootDir = new DirectoryInfo(root);
            } catch (Exception exception) {
                Console.WriteLine("Error opening directory '{0}': {1}", root, exception.Message);
            }
            if (rootDir != null && rootDir.Exists)
            {
                Stack <DirectoryInfo> searchStack = new Stack <DirectoryInfo>();
                HashSet <string>      visitedDirs = new HashSet <string>();
                searchStack.Push(rootDir);
                visitedDirs.Add(rootDir.FullName);
                ++numDirsToProcess;
                ChangeOwner(rootDir, currentOwnerId, newOwnerId);

                while (searchStack.Count != 0)
                {
                    DirectoryInfo dirInfo = searchStack.Pop();
                    ++numDirsProcessed;

                    Console.SetCursorPosition(0, Math.Max(0, Console.CursorTop - 2));

                    try {
                        // Change all files in dir
                        IEnumerable <FileInfo> fileEntries = dirInfo.EnumerateFiles();
                        foreach (FileInfo fileEntry in fileEntries)
                        {
                            ChangeOwner(fileEntry, currentOwnerId, newOwnerId);
                            ++numFilesProcessed;
                        }

                        // Change and add all subdirs
                        IEnumerable <DirectoryInfo> dirEntries = dirInfo.EnumerateDirectories();
                        foreach (DirectoryInfo dirEntry in dirEntries)
                        {
                            // Ignore reparse points
                            if ((dirEntry.Attributes & FileAttributes.ReparsePoint) == 0)
                            {
                                ++numDirsToProcess;
                                ChangeOwner(dirEntry, currentOwnerId, newOwnerId);
                                searchStack.Push(dirEntry);
                                visitedDirs.Add(dirEntry.FullName);
                            }
                            else
                            {
                                ++numReparsePoints;
                            }
                        }
                    } catch (Exception exception) {
                        Console.WriteLine("Exception '{0}'", exception.Message);
                    }

                    Console.WriteLine("Processed {0}\\{1} directories", numDirsProcessed, numDirsToProcess);
                    Console.WriteLine("Processed {0} files", numFilesProcessed);
                }
            }

            Console.WriteLine("-------------------------");
            Console.WriteLine("         Summary");
            Console.WriteLine("-------------------------");
            Console.WriteLine("Successfully changed {0} directories and files", sNumChanged);
            Console.WriteLine("Skipped {0} linked directories", numReparsePoints);
            Console.WriteLine();
        }
Example #11
0
 static void ChangeOwner(FileInfo fileInfo, System.Security.Principal.IdentityReference currentOwnerId, System.Security.Principal.IdentityReference newOwnerId)
 {
     CheckAttributes(fileInfo);
     try {
         FileSecurity fileSec = fileInfo.GetAccessControl();
         if (fileSec.GetOwner(typeof(System.Security.Principal.SecurityIdentifier)) == currentOwnerId)
         {
             ++sNumChanged;
             if (!sDryRun)
             {
                 fileSec.SetOwner(newOwnerId);
                 fileInfo.SetAccessControl(fileSec);
             }
             Console.WriteLine("Set ownership on file '{0}' to '{1}'", fileInfo.FullName, newOwnerId.ToString());
         }
     } catch (ArgumentException) {
         Console.WriteLine("Weird exception processing file '{0}'", fileInfo.FullName);
     } catch (Exception exception) {
         Console.WriteLine("Exception processing file '{0}': '{1}'", fileInfo.FullName, exception.Message);
     }
 }
 public ActiveDirectoryAccessRule(System.Security.Principal.IdentityReference identity, ActiveDirectoryRights adRights, System.Security.AccessControl.AccessControlType type, System.Guid objectType)
 {
 }
 public ExtendedRightAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type, ActiveDirectorySecurityInheritance inheritanceType) : base(default(System.Security.Principal.IdentityReference), default(ActiveDirectoryRights), default(System.Security.AccessControl.AccessControlType))
 {
     Contract.Requires(identity != null);
 }
 public PropertySetAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type, PropertyAccess access, System.Guid propertySetType, ActiveDirectorySecurityInheritance inheritanceType)
 {
 }
 public PipeAuditRule(System.Security.Principal.IdentityReference identity, System.IO.Pipes.PipeAccessRights rights, System.Security.AccessControl.AuditFlags flags) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AuditFlags))
 {
 }
 public virtual void PurgeAuditRules(System.Security.Principal.IdentityReference identity)
 {
 }
 public override AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags)
 {
     return(default(AuditRule));
 }
 public abstract virtual AccessRule AccessRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
 {
 }
Example #19
0
 public virtual System.Security.AccessControl.AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, System.Security.AccessControl.InheritanceFlags inheritanceFlags, System.Security.AccessControl.PropagationFlags propagationFlags, System.Security.AccessControl.AuditFlags flags, System.Guid objectType, System.Guid inheritedObjectType)
 {
     throw null;
 }
 public abstract virtual AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags)
 {
 }
Example #21
0
 public FileSystemAccessRule(System.Security.Principal.IdentityReference identity, FileSystemRights fileSystemRights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(InheritanceFlags), default(PropagationFlags), default(AccessControlType))
 {
 }
 public ListChildrenAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type) : base(default(System.Security.Principal.IdentityReference), default(ActiveDirectoryRights), default(System.Security.AccessControl.AccessControlType))
 {
     Contract.Requires(identity != null);
 }
Example #23
0
 public ExtendedRightAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.AccessControlType type, System.Guid extendedRightType, ActiveDirectorySecurityInheritance inheritanceType, System.Guid inheritedObjectType)
 {
 }
Example #24
0
 public override AccessRule AccessRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType type)
 {
     return(new JobObjectAccessRule(identityReference, (JobObjectRights)accessMask, type));
 }
Example #25
0
 public MutexAccessRule(System.Security.Principal.IdentityReference identity, MutexRights eventRights, AccessControlType type) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(InheritanceFlags), default(PropagationFlags), default(AccessControlType))
 {
 }
Example #26
0
 public override AuditRule AuditRuleFactory(System.Security.Principal.IdentityReference identityReference, int accessMask, bool isInherited, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AuditFlags flags)
 {
     return(new JobObjectAuditRule(identityReference, (JobObjectRights)accessMask, flags));
 }
 public MutexAuditRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.MutexRights eventRights, System.Security.AccessControl.AuditFlags flags) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AuditFlags))
 {
 }
 // Constructors
 public CryptoKeyAccessRule(System.Security.Principal.IdentityReference identity, CryptoKeyRights cryptoKeyRights, AccessControlType type)
 {
 }
 public SemaphoreAccessRule(System.Security.Principal.IdentityReference identity, System.Security.AccessControl.SemaphoreRights eventRights, System.Security.AccessControl.AccessControlType type) : base(default(System.Security.Principal.IdentityReference), default(int), default(bool), default(System.Security.AccessControl.InheritanceFlags), default(System.Security.AccessControl.PropagationFlags), default(System.Security.AccessControl.AccessControlType))
 {
 }
Example #30
0
 // Constructors
 public SemaphoreAuditRule(System.Security.Principal.IdentityReference identity, SemaphoreRights eventRights, AuditFlags flags)
 {
 }