Reorder ACL


Iowna Uass

I have a module that I'm using to set directory permissions on a series of
I'm using the following code to set the permissions.

' Adds an ACL entry on the specified directory for the specified
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,

' Set the new access settings.

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

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?



Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question