ExportSecurityContext function (sspi.h)

The ExportSecurityContext function creates a serialized representation of a security context that can later be imported into a different process by calling
ImportSecurityContext. The process that imports the security context must be running on the same computer as the process that called ExportSecurityContext.

Syntax

KSECDDDECLSPEC SECURITY_STATUS SEC_ENTRY ExportSecurityContext(
  [in]            PCtxtHandle phContext,
  [in]            ULONG       fFlags,
  [out]           PSecBuffer  pPackedContext,
  [out, optional] void        **pToken
);

Parameters

[in] phContext

A handle of the security context to be exported.

[in] fFlags

This parameter can be a bitwise-OR combination of the following values.

Value Meaning
SECPKG_CONTEXT_EXPORT_RESET_NEW
1 (0x1)
The new security context is reset to its initial state.
SECPKG_CONTEXT_EXPORT_DELETE_OLD
2 (0x2)
The old security context is deleted.
SECPKG_CONTEXT_EXPORT_TO_KERNEL
4 (0x4)
This value is not supported.

Windows Server 2003 and Windows XP/2000:  The security context is to be exported to the kernel.This value is supported only in Schannel kernel mode.

[out] pPackedContext

A pointer to a buffer of type SECBUFFER_EMPTY that receives the serialized security context. When you have finished using this context, free it by calling the FreeContextBuffer function.

[out, optional] pToken

A pointer to receive the handle of the context's token.

When you have finished using the user token, release the handle by calling the CloseHandle function.

Return value

If the function succeeds, the function returns SEC_E_OK.

If the function fails, it returns one of the following error codes.

Return code Description
SEC_E_INSUFFICIENT_MEMORY
There is not enough memory available to complete the requested action.
SEC_E_INVALID_HANDLE
The phContext parameter does not point to a valid handle.
SEC_E_NOT_SUPPORTED
Schannel kernel mode does not support this function.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header sspi.h (include Security.h)
Library Secur32.lib
DLL Secur32.dll

See also

FreeContextBuffer

ImportSecurityContext

SSPI Functions