DuplicateToken

  BOOL DuplicateToken(ExistingTokenHandle, ImpersonationLevel, DuplicateTokenHandle)    
  HANDLE ExistingTokenHandle;    
  SECURITY_IMPERSONATION_LEVEL ImpersonationLevel;    
  PHANDLE DuplicateTokenHandle;    

The DuplicateToken function creates a new token that is a duplicate of an existing token. The new token will be an impersonation token of the supplied level.

Parameters

ExistingTokenHandle

Is a handle to a token already open for TOKEN_DUPLICATE access.

ImpersonationLevel

Supplies the impersonation level of the new token.

DuplicateTokenHandle

Returns the handle to the new token. The handle will have TOKEN_IMPERSONATE and TOKEN_QUERY access to the new token.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.