chsvlib
chsv helper source code

◆ CreateDACL() [3/3]

AutoACL Chusov::Win32::Security::CreateDACL ( std::initializer_list< ACCESS_ALLOWED_ACE_INFO lstAllowed,
std::initializer_list< ACCESS_DENIED_ACE_INFO lstDenied,
DWORD  dwAclRevision = ACL_REVISION 
)

Allocates and returns a managed pointer to a discretionary access control list (DACL), created from access control entries (ACEs), passed to the function within initializer list parameters. Each ACE is specified only by a string of a principal name, possibly with a corresponding domain name, and by a respective access control mask, as defined by the ACE_INFO class template. If both ACE storages are empty, the function returns a "prohibit anyone from anything" empty DACL. .

Parameters
lstAllowedis list of ACCESS_ALLOWED_ACE_INFO objects, specifying access-allowed ACEs to be included into the created DACL.
lstDeniedis list of ACCESS_DENIED_ACE_INFO objects, specifying access-denied ACEs to be included into the created DACL.
dwAclRevisionis a revision level of the ACL object being created. See InitializeAcl for the proper values of the parameter.
Returns
The function returns a smart AutoACL pointer to a newly created DACL, described by the ACL Windows API structure. If no access-control entries were supplied to the function through the refAccessAllowedACEs or refAccessDeniedACEs containers, the function returns an empty DACL, which prohibits any principal from any access to an object, the DACL is assigned to.

The function creates a DACL from the given lists of ACCESS_ALLOWED_ACE_INFO and ACCESS_DENIED_ACE_INFO representations of access-allowed and access-denied control entries respectively. Each element of the both lists requires a string holding principal name and a corresponding access-control Windows bitmask.

If both lists are empty, the function returns an empty DACL, which prohibits any principal from any access to an object, which the DACL is assigned to. See "Null DACLs and Empty DACLs".

Exceptions
std::bad_allocThe function was unable to allocate a required amount of memory to complete the request.
Chusov::Exceptions::ArithmeticOverflowExceptionA size, in bytes, of the DACL to be allocated must fit 32 bits (as specified by DWORD values), but it does not.
Chusov::Exceptions::ChsvCodeExceptionSystem-level error occurred.
See also
CreateDACL(AllowedInputIterator, AllowedInputIterator, DeniedInputIterator, DeniedInputIterator, DWORD dwAclRevision); creates a DACL from two ranges of access-control entries within half-intervals specified by iterators;
CreateDACL(const allowed_ace_container_t& refAccessAllowedACEs, const denied_ace_container_t& refAccessDeniedACEs, DWORD dwAclRevision); creates a DACL from C++ containers of access-control lists.