D
Dave Coate
Hi,
I am attempting to use APIs via vb.net to view and ultimately modify
file permissions. I made it part way and got stuck. I am able to use
GetExplicitEntriesFromAcl and get the number of ACEs, but I can not
find a way to get at the individual ACEs in the returned array.
Here is a snippet of the code:
<DllImport("Advapi32.DLL", CharSet:=CharSet.Auto, SetLastError:=True)>
_
Public Shared Function GetExplicitEntriesFromAcl( _
ByVal pacl As IntPtr, _
ByRef pcCountOfExplicitEntries As UInt32, _
ByRef pListOfExplicitEntries() As EXPLICIT_ACCESS) As Int32
End Function
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Public Structure EXPLICIT_ACCESS
Public grfAccessPermissions As UInt32
Public grfAccessMode As ACCESS_MODE
Public grfInheritance As UInt32
Public Trustee As TRUSTEE
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Public Structure TRUSTEE
Public pMultipleTrustee As IntPtr
Public MultipleTrusteeOperation As MULTIPLE_TRUSTEE_OPERATION
Public TrusteeForm As TRUSTEE_FORM
Public TrusteeType As TRUSTEE_TYPE
Public ptstrName As String
End Structure
Dim nACE As UInt32
Dim ACEs() As EXPLICIT_ACCESS
Dim ACE As EXPLICIT_ACCESS
' Obtain the array of ACEs from the DACL.
ACECount = Convert.ToUInt32(0)
Result = GetExplicitEntriesFromAcl(DACL, _
nACE, _
ACEs)
In my program nACE returns the correct number for the file I am
testing. I can add and subtract users and groups from the Explorer
interface and this number increases and decreases as expected.
However, I can not figure out how to get information from an
individual ACE in the ACEs array. What do I do now?
Thanks,
Dave
I am attempting to use APIs via vb.net to view and ultimately modify
file permissions. I made it part way and got stuck. I am able to use
GetExplicitEntriesFromAcl and get the number of ACEs, but I can not
find a way to get at the individual ACEs in the returned array.
Here is a snippet of the code:
<DllImport("Advapi32.DLL", CharSet:=CharSet.Auto, SetLastError:=True)>
_
Public Shared Function GetExplicitEntriesFromAcl( _
ByVal pacl As IntPtr, _
ByRef pcCountOfExplicitEntries As UInt32, _
ByRef pListOfExplicitEntries() As EXPLICIT_ACCESS) As Int32
End Function
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Public Structure EXPLICIT_ACCESS
Public grfAccessPermissions As UInt32
Public grfAccessMode As ACCESS_MODE
Public grfInheritance As UInt32
Public Trustee As TRUSTEE
End Structure
<StructLayout(LayoutKind.Sequential, Pack:=1)> _
Public Structure TRUSTEE
Public pMultipleTrustee As IntPtr
Public MultipleTrusteeOperation As MULTIPLE_TRUSTEE_OPERATION
Public TrusteeForm As TRUSTEE_FORM
Public TrusteeType As TRUSTEE_TYPE
Public ptstrName As String
End Structure
Dim nACE As UInt32
Dim ACEs() As EXPLICIT_ACCESS
Dim ACE As EXPLICIT_ACCESS
' Obtain the array of ACEs from the DACL.
ACECount = Convert.ToUInt32(0)
Result = GetExplicitEntriesFromAcl(DACL, _
nACE, _
ACEs)
In my program nACE returns the correct number for the file I am
testing. I can add and subtract users and groups from the Explorer
interface and this number increases and decreases as expected.
However, I can not figure out how to get information from an
individual ACE in the ACEs array. What do I do now?
Thanks,
Dave