QueryCredentialsAttributesA function (sspi.h)

Retrieves the attributes of a credential, such as the name associated with the credential. The information is valid for any security context created with the specified credential.

Syntax

SECURITY_STATUS SEC_ENTRY QueryCredentialsAttributesA(
  [in]  PCredHandle   phCredential,
  [in]  unsigned long ulAttribute,
  [out] void          *pBuffer
);

Parameters

[in] phCredential

A handle of the credentials to be queried.

[in] ulAttribute

Specifies the attribute to query. This parameter can be any of the following attributes.

Value Meaning
SECPKG_CRED_ATTR_CERT
Returns the certificate thumbprint in a pbuffer of type SecPkgCredentials_Cert.

This attribute is only supported by Kerberos.

Windows Server 2008 R2, Windows 7, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP:  This attribute is not available.

SECPKG_CRED_ATTR_NAMES
Returns the name of a credential in a pbuffer of type SecPkgCredentials_Names.

This attribute is not supported by Schannel in WOW64 mode.

SECPKG_ATTR_SUPPORTED_ALGS
Returns the supported algorithms in a pbuffer of type SecPkgCred_SupportedAlgs. All supported algorithms are included, regardless of whether they are supported by the provided certificate or enabled on the local computer.

This attribute is supported only by Schannel.

SECPKG_ATTR_CIPHER_STRENGTHS
Returns the cipher strengths in a pbuffer of type SecPkgCred_CipherStrengths.

This attribute is supported only by Schannel.

SECPKG_ATTR_SUPPORTED_PROTOCOLS
Returns the supported algorithms in a pbuffer of type SecPkgCred_SupportedProtocols. All supported protocols are included, regardless of whether they are supported by the provided certificate or enabled on the local computer.

This attribute is supported only by Schannel.

[out] pBuffer

A pointer to a buffer that receives the requested attribute. The type of structure returned depends on the value of ulAttribute.

Return value

If the function succeeds, the return value is SEC_E_OK.

If the function fails, the return value may be one of the following error codes.

Return code Description
SEC_E_INVALID_HANDLE
The handle passed to the function is not valid.
SEC_E_UNSUPPORTED_FUNCTION
The specified attribute is not supported by Schannel. This return value will only be returned when the Schannel SSP is being used.
SEC_E_INSUFFICIENT_MEMORY
The memory that is available is not sufficient to complete the request.

Remarks

The QueryCredentialsAttributes function allows an application to determine several characteristics of a credential, including the name associated with the specified credentials.

Querying the SECPKG_ATTR_CIPHER_STRENGTHS attribute returns a SecPkgCred_CipherStrengths structure. The cipher strength in this structure is the same as the cipher strength in the SCH_CREDENTIALS structure used when a credential was created.

Note  An application can find the system default cipher strength by querying this attribute with a default credential. A default credential is created by calling AcquireCredentialsHandle with a NULL pAuthData parameter.
 
Querying the SECPKG_ATTR_SUPPORTED_ALGS attribute returns a SecPkgCred_SupportedAlgs structure. The algorithms in this structure are compatible with those indicated in the SCH_CREDENTIALS structure used when a credential was created.

Querying the SECPKG_ATTR_SUPPORTED_PROTOCOLS attribute returns a SecPkgCred_SupportedProtocols structure that contains a bit array compatible with the grbitEnabledProtocols field of the SCH_CREDENTIALS structure.

The caller must allocate the structure pointed to by the pBuffer parameter. The security package allocates the buffer for any pointer returned in the pBuffer structure. The caller can call the FreeContextBuffer function to free any pointers allocated by the security package.

Note

The sspi.h header defines QueryCredentialsAttributes 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

AcquireCredentialsHandle

FreeContextBuffer

SCH_CREDENTIALS

SSPI Functions

SecPkgCred_CipherStrengths

SecPkgCred_SupportedAlgs

SecPkgCred_SupportedProtocols

SecPkgCredentials_Names