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
Mattias Sj?gren - 28 Sep 2004 20:25 GMT
Dave,
See if this helps
http://dotnetinterop.com/faq/?q=CalleeAllocatedStructArray
Mattias

Signature
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Dave Coate - 30 Sep 2004 17:41 GMT
Mattias,
That is exactly what I was looking for. I was able to adapt it for my
purposes quite easily.
Thanks!
Dave
Mattias Sjögren <mattias.dont.want.spam@mvps.org> wrote in message news:<eZbRtCZpEHA.592@TK2MSFTNGP11.phx.gbl>...
> Dave,
>
[quoted text clipped - 3 lines]
>
> Mattias