When setting the owner of a preexisting folder in Server 2008 R2, is there a way to make this propagate to all of the sub containers under the object? You can do this in the Properties diag, but I do not see a switch for this.
I am looking for a way to avoid recusing through the sub containers to do this.
This code will switch the owner for only the top level directory.
DirectoryInfo myDirectoryInfo = new DirectoryInfo("PATH HERE");
DirectorySecurity myDirectorySecurity = myDirectoryInfo.GetAccessControl();
System.Security.Principal.IdentityReference myOwner =
new System.Security.Principal.NTAccount("TARGET OWNER ACCOUNT");
myDirectorySecurity.SetOwner(myOwner);
myDirectoryInfo.SetAccessControl(myDirectorySecurity);