#ifndef _NTSAM_H
/**
* Creates a user account of the specified type and returns the granted access.
*
* \param DomainHandle A handle to the domain.
* \param AccountName The name of the user account to create.
* \param AccountType The user account type to create.
* \param DesiredAccess The access requested for the returned user handle.
* \param UserHandle Receives a handle to the created user.
* \param GrantedAccess Receives the access granted to UserHandle.
* \param RelativeId Receives the RID of the created user.
* \return NTSTATUS indicating success or failure.
*/
NTSYSAPI
NTSTATUS
NTAPI
SamCreateUser2InDomain(
_In_ SAM_HANDLE DomainHandle,
_In_ PCUNICODE_STRING AccountName,
_In_ ULONG AccountType,
_In_ ACCESS_MASK DesiredAccess,
_Out_ PSAM_HANDLE UserHandle,
_Out_ PULONG GrantedAccess,
_Out_ PULONG RelativeId
);
View code on GitHubThis function is a wrapper over an RPC method documented in the [MS-SAMR] specification.