tags:

views:

18

answers:

2
A: 

AcquireCredentialsHandle will not allocate space for credentials, shouldnt have NULLed the credentials and credentialsExpiry structures ...

hatchetman82
+1  A: 

You need to change the last section of code to look like this:

CredHandle credentials;
TimeStamp credentialsExpiry;

SECURITY_STATUS result = AcquireCredentialsHandleW(_T("USER"), _T("NTLM"), 
    SECPKG_CRED_OUTBOUND, NULL, &identity, NULL, NULL, 
    &credentials, &credentialsExpiry);

Per MSDN docs, the pointers in the last 2 parameters are not optional on your call:

phCredential [out]

A pointer to a CredHandle structure to receive the credential handle.

ptsExpiry [out]

A pointer to a TimeStamp structure that receives the time at which the returned credentials expire. The value returned in this TimeStamp structure depends on the security package. The security package must return this value in local time.

This parameter is set to a constant maximum time. There is no expiration time for Digest security contexts or credentials or when using the Digest SSP.

When using the Schannel SSP, this parameter is optional. When the credential to be used for authentication is a certificate, this parameter receives the expiration time for that certificate. If no certificate was supplied, then a maximum time value is returned.

Steve Townsend