I
Iowna Uass
Hi,
I have a module that I'm using to set directory permissions on a series of
folders.
I'm using the following code to set the permissions.
' Adds an ACL entry on the specified directory for the specified
account.
Sub AddDirectorySecurity(ByVal FileName As String, _
ByVal Account As String, _
ByVal Rights As FileSystemRights, _
ByVal ControlType As AccessControlType)
' Create a new DirectoryInfoobject.
Dim dInfo As New DirectoryInfo(FileName)
Dim IHFlags As InheritanceFlags = InheritanceFlags.ContainerInherit
+ InheritanceFlags.ObjectInherit
' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
' Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights,
ControlType))
' Set the new access settings.
dInfo.SetAccessControl(dSecurity)
End Sub
When I run the code on certain machines (right out of the box), I get an
error regarding the ACL not being canonical order.
A manual fix is to right click on the folder, select properties and select
the security tab.
A popup informs me that the ACL is not in order and asks if I want to
reorder it.
What I am looking for is a VB dot Net code sample to do the above manual fix
programmatically.
I've found the class to check if the ACL is in order (CommonAcl.IsCanonical)
and I've found a few samples using ADsSecurity.dll to set the order (MS kb
269159), but I'm not interested in deploying and registering an extra dll
with my installer.
I've also found a number of scripting examples to reorder the ACL, but I'm
after a vb or c# example using vs 2005 or 2008.
Has anyone else had the need to do this? Do you have an example?
Thanks.
I have a module that I'm using to set directory permissions on a series of
folders.
I'm using the following code to set the permissions.
' Adds an ACL entry on the specified directory for the specified
account.
Sub AddDirectorySecurity(ByVal FileName As String, _
ByVal Account As String, _
ByVal Rights As FileSystemRights, _
ByVal ControlType As AccessControlType)
' Create a new DirectoryInfoobject.
Dim dInfo As New DirectoryInfo(FileName)
Dim IHFlags As InheritanceFlags = InheritanceFlags.ContainerInherit
+ InheritanceFlags.ObjectInherit
' Get a DirectorySecurity object that represents the
' current security settings.
Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
' Add the FileSystemAccessRule to the security settings.
dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights,
ControlType))
' Set the new access settings.
dInfo.SetAccessControl(dSecurity)
End Sub
When I run the code on certain machines (right out of the box), I get an
error regarding the ACL not being canonical order.
A manual fix is to right click on the folder, select properties and select
the security tab.
A popup informs me that the ACL is not in order and asks if I want to
reorder it.
What I am looking for is a VB dot Net code sample to do the above manual fix
programmatically.
I've found the class to check if the ACL is in order (CommonAcl.IsCanonical)
and I've found a few samples using ADsSecurity.dll to set the order (MS kb
269159), but I'm not interested in deploying and registering an extra dll
with my installer.
I've also found a number of scripting examples to reorder the ACL, but I'm
after a vb or c# example using vs 2005 or 2008.
Has anyone else had the need to do this? Do you have an example?
Thanks.