Share via


CAccessToken::CreatePrimaryToken

Call this method to create a new primary token.

bool CreatePrimaryToken( 
   CAccessToken* pPri, 
   DWORD dwDesiredAccess = MAXIMUM_ALLOWED, 
   const CSecurityAttributes* pTokenAttributes = NULL 
) const throw(...);

Parameters

  • pPri
    Pointer to the new CAccessToken object.

  • dwDesiredAccess
    Specifies the requested access rights for the new token. The default, MAXIMUM_ALLOWED, requests all access rights that are valid for the caller. See Access Rights and Access Masks for more on access rights.

  • pTokenAttributes
    Pointer to a SECURITY_ATTRIBUTES structure that specifies a security descriptor for the new token and determines whether child processes can inherit the token. If pTokenAttributes is NULL, the token gets a default security descriptor and the handle cannot be inherited.

Return Value

Returns true on success, false on failure.

Remarks

CreatePrimaryToken calls DuplicateTokenEx to create a new primary token.

Requirements

Header: atlsecurity.h

See Also

Reference

CAccessToken Class

CAccessToken::CreateImpersonationToken

CAccessToken::CreateRestrictedToken