Retrieves a service ticket for an authenticated identity.

HRESULT AuthIdentityToService(
       IN PassportIdentityHandle hIdentity,
       IN LPCWSTR szServiceTarget,
       IN OPTIONAL LPCWSTR szServicePolicy,
       IN DWORD dwTokenRequestFlags,
       OUT OPTIONAL LPWSTR *szToken,
       OUT OPTIONAL DWORD *pdwResultFlags,
       OUT OPTIONAL BYTE **ppbSessionKey,
       OUT OPTIONAL DWORD *pcbSessionKeyLength


The identity handle for which a service ticket is being requested.


A string indicating the service name for which the ticket is being requested. This name is a unique identifier chosen by the service when it registered with the identity service. This value may or may not be the same as the service's domain name.


Optional. A string that expresses a policy that will be evaluated when determining whether the supplied authenticated identity will be granted access to the service. This string determines the type of ticket to be issued for a particular target service. The service and the client application will determine how this policy is obtained or generated.


Set to SERVICETOKENFLAGS.SERVICE_TOKEN_FROM_CACHE to get persisted service tickets and certificates. SERVICETOKENFLAGS.SERVICE_TOKEN_FROM_CACHE is only used when you are obtaining the ticket from a previously submitted ticket request.


Optional. The returned service ticket.


Optional. The type of service ticket returned. Use one of the values from SERVICETOKENFLAGS.SERVICE_TOKEN_FROM_CACHE here.


Optional. If the service ticket format supports it, this parameter will contain a session key that matches the symmetric or asymmetric session key, depending on the policy, inside the service ticket.


Optional. The length of the returned session key.

The following table describes the return values for this method.

Return Code



Cannot connect to authentication service.


The identity has not been authenticated.


The service ticket cannot be retrieved.


Request parameters are missing.


The ticket returned has no session key.


The service ticket was returned.

The type of service ticket that is returned by this method is determined by the service and the policy for which the ticket is being requested. A ticket and a session key may be created as a result of this method call. The memory allocated for these objects may be freed by calling the PassportFreeMemory method for each object.