R
Roger Tranchez
Hello,
Recently, a manager from our company moved a lot of files and folders from
within our server's main data disk, and as a result, that data are not
inheriting the acls from the place they are now (it is a normal behaviour, of
course).
Instead of this, on the "inherited from" column you can read "Parent Object"
instead of the new folder it should inherit from.
As changing they manually could be too slooow (there are a lot of explicit
permissions that are not inherited from their parent folders, lots of groups,
and they all SHOULD BE PRESERVED) I was trying to make it with the
System.Security.AccessControl libraries in .net, trying to delete all these
nasty inherited permissions as long as I can find them with a search...
I made the recursive loop to search all the folders (no problem) but when I
use
the following code (the example is for only one file for the sake of
simplicity)...
Dim fi As New FileInfo("C:\test\b\f2.txt")
Dim fs As New FileSecurity
Dim obTypeToGet As Type
fs = fi.GetAccessControl()
obTypeToGet = Type.GetType("System.Security.Principal.NTAccount")
For Each ace As FileSystemAccessRule In fs.GetAccessRules(True,
True, obTypeToGet)
if ace.IsInherited and "THEY'RE INHERITED FROM 'PARENT FOLDER'" then
'Here I should delete all the permissions if I find that
"inherited from" is "Parent object"
'instead of a concrete folder you know... as it 'll indicate
they were moved.
endif
Next
.... I am not unable to:
-- Identify that "inherited from parent object" (ace.IsInherited=True ok...
but from wich folder ?)
-- I don't know what to do when I will be unable to identify those folders...
should I set it to not inherit , then delete all acls and then set it
again to inherit from actual parent object ?... how ?
Thanks !
Recently, a manager from our company moved a lot of files and folders from
within our server's main data disk, and as a result, that data are not
inheriting the acls from the place they are now (it is a normal behaviour, of
course).
Instead of this, on the "inherited from" column you can read "Parent Object"
instead of the new folder it should inherit from.
As changing they manually could be too slooow (there are a lot of explicit
permissions that are not inherited from their parent folders, lots of groups,
and they all SHOULD BE PRESERVED) I was trying to make it with the
System.Security.AccessControl libraries in .net, trying to delete all these
nasty inherited permissions as long as I can find them with a search...
I made the recursive loop to search all the folders (no problem) but when I
use
the following code (the example is for only one file for the sake of
simplicity)...
Dim fi As New FileInfo("C:\test\b\f2.txt")
Dim fs As New FileSecurity
Dim obTypeToGet As Type
fs = fi.GetAccessControl()
obTypeToGet = Type.GetType("System.Security.Principal.NTAccount")
For Each ace As FileSystemAccessRule In fs.GetAccessRules(True,
True, obTypeToGet)
if ace.IsInherited and "THEY'RE INHERITED FROM 'PARENT FOLDER'" then
'Here I should delete all the permissions if I find that
"inherited from" is "Parent object"
'instead of a concrete folder you know... as it 'll indicate
they were moved.
endif
Next
.... I am not unable to:
-- Identify that "inherited from parent object" (ace.IsInherited=True ok...
but from wich folder ?)
-- I don't know what to do when I will be unable to identify those folders...
should I set it to not inherit , then delete all acls and then set it
again to inherit from actual parent object ?... how ?
Thanks !