Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SetEntriesInAcl (advapi32)
 
.
Summary
The SetEntriesInAcl function creates a new access control list (ACL) by merging new access control or audit control information into an existing ACL.

C# Signature:

[DllImport("advapi32.dll", CharSet=CharSet.Auto)]
static extern uint SetEntriesInAcl(
    uint cCountOfExplicitEntries,
    EXPLICIT_ACCESS[] pListOfExplictEntries,
    IntPtr OldAcl,
    out IntPtr NewAcl);

VB Signature:

Declare Function SetEntriesInAcl Lib "advapi32.dll" ( _
    ByVal cCountOfExplicitEntries As Integer, _
    ByRef pListOfExplicitEntries As EXPLICIT_ACCESS, _
    ByVal OldAcl As IntPtr, _
    ByRef NewAcl As IntPtr) As Integer

User-Defined Types:

EXPLICIT_ACCESS

Notes:

Returns ERROR_SUCCESS on success or an error code on failure. The new ACL must be freed with LocalFree.

Tips & Tricks:

Please add some!

C# Sample Code:

Please add some!

VB.Net Sample Code:

    Private Const SET_ACCESS = 2&
    ' Inheritance Flags
    Private Const CONTAINER_INHERIT_ACE = &H2
    Private Const OBJECT_INHERIT_ACE = &H1

    Dim pNewDACL, pOldDACL As IntPtr
    Dim ea As EXPLICIT_ACCESS
    Dim Win32Error As Win32Exception
    Dim ret, iPerm As Integer

    ' build an explicit access structure
    BuildExplicitAccessWithName(ea, strUserName, iPerm, SET_ACCESS, CONTAINER_INHERIT_ACE Or OBJECT_INHERIT_ACE)

    ' merge this Explict Access with the existing DACL
    ret = SetEntriesInAcl(1, ea, pOldDACL, pNewDACL)
    If ret <> 0 Then
        Win32Error = New Win32Exception(ret)
        Throw New Exception(Win32Error.Message)
    End If

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions