Location: Symbol Reference > Classes > TJwSecurityToken Class > TJwSecurityToken Methods > TJwSecurityToken.ConvertToPrimaryToken Method
JWSCL Documentation
ContentsIndexHome
PreviousUpNext
TJwSecurityToken.ConvertToPrimaryToken Method
Pascal
procedure ConvertToPrimaryToken(const aDesiredAccess: TJwAccessMask); virtual;
Parameters 
Description 
const aDesiredAccess: TJwAccessMask 
Receives the desired access for this token. The access types can be get from the following list. Access flags must be concatenated with or operator. If you want to use DuplicateToken or creating an primary token (by ConvertToPrimaryToken) you must specify TOKEN_DUPLICATE.
See CreateTokenByProcess CreateTokenByProcess for a list of access rights.
defines the access to the new primary token. It can be MAXIMUM_ALLOWED to get the maximum possible access. Possible access rights are always equal or lower than the given ones when the handle was opened 

ConvertToPrimaryToken converts the token into a primary (or process) token. It does nothing if the token is already a primary token. The token instance must be opened with TOKEN_DUPLICATE access right. 

Actually you can impersonate a shared token. The primary token will be copied into the instance property TokenHandle. The old handle will not be closed if Share is set to true. You must save the old value to close it by yourself. 

Because the old handle is discarded you must call these functions again : GetTokenPrivileges 

ConvertToPrimaryToken needs the following access rights:

  • TOKEN_QUERY
  • READ_CONTROL
  • TOKEN_DUPLICATE
You can use TOKEN_READ instead of TOKEN_QUERY and READ_CONTROL. 

 

Exceptions 
Description 
will be raised if the call to DuplicateTokenEx failed. 
will be raised if the token does not have the access TOKEN_READ and TOKEN_DUPLICATE 
Copyright (c) 2010. All rights reserved.
This help was created by Doc-O-Matic sponsored by toolsfactory software inc.
What do you think about this topic? Send feedback!