chsvlib
chsv helper source code

◆ CreateSecurityDescriptor() [4/4]

AutoSecurityDescriptor Chusov::Win32::Security::CreateSecurityDescriptor ( PSID  pOwner,
PSID  pGroup,
PACL  pDacl 
)

Allocates and initializes a self-relative security descriptor with the specified owner and group, identified by security identifiers (SID), and with a discretionary access control list (DACL). Each of these elements of the created security descriptor are optional.

Parameters
[in]pOwneris an optional pointer to a SID of a security descriptor owner. If the pointer is NULL, the owner is not set.
[in]pGroupis an optional pointer to a SID of a security descriptor group. If the pointer is NULL, the group is not set.
[in]pDaclis an optional pointer to a DACL to be assigned to the created security descriptor. If the pointer is NULL, the created security descriptor will not have the DACL.
Returns
The function returns a smart AutoSecurityDescriptor pointer to the created self-relative security descriptor.

A revision of the created DACL corresponds to ACL_REVISION constant. See InitializeAcl for more detailed information.

The following example demonstrates a usage of the function:

PSECURITY_DESCRIPTOR GetSD()
{
NULL, Chusov::Memory::AutoData<PACL>(Chusov::Win32::Security::CreateDACL({{L"\\\\OPROOT\\lpszTemp", GENERIC_ALL}, {L"HomeUsers", GENERIC_READ}}, {})).get());
}
Helper functionality for working with Win32 APIs.
AutoACL CreateDACL(AllowedInputIterator itAccessAllowedACEsBegin, AllowedInputIterator itAccessAllowedACEsEnd, DeniedInputIterator itAccessDeniedACEsBegin, DeniedInputIterator itAccessDeniedACEsEnd, DWORD dwAclRevision=ACL_REVISION)
Creates a discretionary access control list (DACL) from two sequences of access-allowed and access-de...
Definition: chsvwinutilex.h:1536
AutoSecurityDescriptor CreateSecurityDescriptor(PSID pOwner, PSID pGroup, PACL pDacl)
Allocates and initializes a self-relative security descriptor with the specified owner and group,...
Definition: chsvwinutilex.h:1680
AutoSID GetSidByPrincipalName(LPCWSTR pszPrincipalName)
Returns a smart AutoSID pointer to a security identifier of a principal, specified by its name.
Definition: chsvwinutilex.h:510
A template of a class specifying std::unique_ptr to manage pointers allocated using one of the alloca...
Definition: chsvmem.h:4089
Exceptions
std::bad_allocThe function was unable to allocate a required amount of memory to complete the request.
Chusov::Exceptions::ChsvCodeExceptionSystem-level error occurred.