Platform SDK: Logon Authentication |
The AcquireCredentialsHandle function acquires a handle to pre-existing credentials associated with the user on whose behalf the call is made. These pre-existing credentials are established through a system logon that is not described here.
Note This is not a "login to the network" and does not imply gathering of credentials.
SECURITY_STATUS AcquireCredentialsHandle( SEC_CHAR *pszPrincipal, // name of principal SEC_CHAR *pszPackage, // name of package ULONG fCredentialUse, // flags indicating use PLUID pvLogonID, // pointer to logon identifier PVOID pAuthData, // package-specific data PVOID pGetKeyFn, // pointer to GetKey function PVOID pvGetKeyArgument, // value to pass to GetKey PCredHandle phCredential, // credential handle PTimeStamp ptsExpiry // lifetime of the returned credentials );
Note If the process requesting the handle does not have access to the credentials, the function returns an error. A null string indicates that the process requires a handle to the credentials of the user under whose security context it is executing.
Value | Meaning |
---|---|
SECPKG_CRED_INBOUND | Used to validate an incoming credential. |
SECPKG_CRED_OUTBOUND | Use to use a local credential to prepare an outgoing token. |
SECPKG_CRED_BOTH | Validate an incoming credential or use a local credential to prepare an outgoing token. |
If the function succeeds, the return value is SEC_E_OK.
If the function fails, the return value can be one of the following error codes.
Value | Meaning |
---|---|
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 | Not enough memory is available to complete the request. |
SEC_E_INTERNAL_ERROR | The Local Security Authority (LSA) cannot be contacted. |
SEC_E_SECPKG_NOT_FOUND | The requested security package does not exist. |
The AcquireCredentialsHandle function returns a handle to the credentials of a principal (such as a user or client) as used by a specific security package. The handle returned can be used in subsequent calls to the AcceptSecurityContext and InitializeSecurityContext functions.
AcquireCredentialsHandle does not let a process obtain a handle to credentials that are not related to the process; in other words, a process cannot get the credentials of another user who is logged on to the same computer.
AcquireCredentialsHandle uses the following algorithm to determine whether to grant the request for a handle to the credentials.
If the caller is a system process with the SE_TCB_NAME privilege (for example, an FSP), and the caller provides both the name and logon identifier, the function verifies that they match before returning the credentials. If only one is provided, the function returns a handle to that identifier.
A caller that is not a system process can only obtain a handle to the credentials under which it is running. The caller can provide the name or the logon identifier, but it must be for the current session or the request fails.
A package may call the function in pGetKeyFn provided by the RPC run-time transport. If the transport does not support the notion of callback to retrieve credentials, this parameter must be NULL.
For kernel mode callers, the following differences must be noted: The two string parameters are Unicode strings, and the buffer values must be allocated in process virtual memory, not from the pool.
When you no longer need the returned credentials, call the FreeCredentialsHandle function to free the memory used by the credentials.
The prototype for this function can be found in Sspi.h.
Windows NT/2000: Requires Windows NT 3.51 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Sspi.h; include Security.h.
Library: Use Secur32.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
AcceptSecurityContext, InitializeSecurityContext, FreeCredentialsHandle