ImportSecurityContextA function (sspi.h)

The ImportSecurityContext function imports a security context. The security context must have been exported to the process calling ImportSecurityContext by a previous call to ExportSecurityContext.

Syntax

SECURITY_STATUS SEC_ENTRY ImportSecurityContextA(
  [in]           LPSTR       pszPackage,
  [in]           PSecBuffer  pPackedContext,
  [in, optional] VOID        *Token,
  [out]          PCtxtHandle phContext
);

Parameters

[in] pszPackage

A string that contains the name of the security package to which the security context was exported.

[in] pPackedContext

A pointer to a buffer that contains the serialized security context created by ExportSecurityContext.

[in, optional] Token

A handle to the context's token.

[out] phContext

A handle of the new security context created from pPackedContext. When you have finished using the context, delete it by calling the DeleteSecurityContext 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_UNKNOWN_CREDENTIALS
The credentials supplied to the package were not recognized.
SEC_E_NO_CREDENTIALS
No credentials are available in the security package.
SEC_E_NOT_OWNER
The caller of the function does not have the necessary credentials.
SEC_E_INSUFFICIENT_MEMORY
There is not enough memory available to complete the requested action.
SEC_E_INTERNAL_ERROR
An error occurred that did not map to an SSPI error code.

Remarks

Note

The sspi.h header defines ImportSecurityContext as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

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

ExportSecurityContext

FreeContextBuffer

SSPI Functions