GetExplicitEntriesFromAcl (advapi32)
Last changed: ozbobwa-118.208.182.144

.
Summary
TODO - a short description

C# Signature:

[DllImport("advapi32.dll", SetLastError=true)]
static extern TODO GetExplicitEntriesFromAcl(TODO);

VB Signature:

    Declare Auto Function GetExplicitEntriesFromAcl Lib "AdvAPI32.DLL" ( _
    ByVal pacl As IntPtr, _
    ByRef pcCountOfExplicitEntries As Integer, _
    ByRef pListOfExplicitEntries As IntPtr _
    ) As Integer

User-Defined Types:

None.

Notes:

    'DWORD GetExplicitEntriesFromAcl(
    '  PACL pacl,
    '  PULONG pcCountOfExplicitEntries,
    '  PEXPLICIT_ACCESS* pListOfExplicitEntries
    ');

Tips & Tricks:

Please add some!

VB.Net Sample Code:

    Dim pSecDesc, pDACL, ACE_ptr, iPtr, StringPtr As IntPtr
    Dim i, num, Ptr_num As Integer
    Dim SidString, NameBuf As String

    ' get the Security Descriptor and DACL
    If GetNamedSecurityInfo(Path, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION, Nothing, Nothing, pDACL, Nothing, pSecDesc) <> 0 Then
        Exit Sub
    End If

    ' Get an array of ACEs
    If GetExplicitEntriesFromAcl(pDACL, num, ACE_ptr) <> 0 Then
        Exit Sub
    End If

    Marshal.FreeHGlobal(ACE_ptr)
    Marshal.FreeHGlobal(pSecDesc)

Alternative Managed API:

If you have .NET v2.0:

For Files

System.Security.AccessControl.FileSecurity

For Registry Keys

System.Security.AccessControl.RegistrySecurity

For Directories

System.Security.AccessControl.DirectorySecurity

Sample Code

  {
    System.Security.AccessControl.FileSecurity secDesc =
      new System.Security.AccessControl.FileSecurity(Path,
      System.Security.AccessControl.AccessControlSections.Access);
    System.Security.AccessControl.AuthorizationRuleCollection aceCollection =
      pSecDesc.GetAccessRules(true, false, typeof(System.Security.Principal.NTAccount));
  }

Documentation