chsvlib
chsv helper source code

◆ CreateACE() [1/2]

AutoACE<ACE_TYPE_ID> Chusov::Win32::Security::CreateACE ( const ACE_INFO< ACE_TYPE_ID > &  ace_info)

Creates an access control entry (ACE) to be used in a discretionary access control list, by a high-level definition of the ACE. .

Template Parameters
ACE_TYPE_IDis an integral constant, of value of either ACCESS_ALLOWED_ACE_TYPE or ACCESS_DENIED_ACE_TYPE, specifying a type of an access control entry being created, which is an access-allowed ACE or an access-denied ACE respectively. See ACE_INFO class template.
Parameters
[in]ace_infois a reference to an object of type, described by the ACE_INFO type template, which is defined with respect to a value of the ACE_TYPE_ID template parameter. That is ACCESS_ALLOWED_ACE_INFO, if ACE_TYPE_ID is equal to ACCESS_ALLOWED_ACE_TYPE, or ACCESS_DENIED_ACE_INFO, if ACE_TYPE_ID is equal to ACCESS_DENIED_ACE_TYPE. The object specifies a high-level definition of the created ACE by a fully or partially qualified principal name and a combination (bit mask) of Windows API access control values. See ACE_INFO definition for more detailed explanation.
Returns
The function returns a smart AutoAce<ACE_TYPE_ID> pointer to the created ACE of either ACCESS_ALLOWED_ACE or ACCESS_DENIED_ACE type, depending on a value of the ACE_TYPE_ID template parameter. The returned value points to data of either of these types with the SID, partially occupying a space that contiguously follows the fields described by the structures.
Exceptions
std::bad_allocCould not allocate a sufficient amount of memory to complete the request.
Chusov::Exceptions::InvalidParameterExceptionA parameter has an invalid value.
Chusov::Exceptions::ChsvCodeExceptiona system-level error occurred. If an invalid SID was specified, the function throws an exception corresponding to the ERROR_INVALID_SID Windows error code.
See also
CreateAccessAllowedACE - a specialization for creating access-allowed ACEs;
CreateAccessDeniedACE - a specialization for creating access-denied ACEs;
CreateACE - an overload receiving a pointer to the native SID representation of a principal through the one's security identifier and an access-control bit mask.