1

The Windows SSPI call AcquireCredentialsHandle returns a time stamp indicating when the credentials handle will expire. The docs seem to be saying that the TimeStamp structure should have the same format as a FILETIME structure. However, when I use this function with the "Kerberos" package, the result makes no sense when treated as a FILETIME:

#include <stdio.h>
#define SECURITY_WIN32
#include <windows.h>
#include <security.h>

int main() {

  TimeStamp expiry;
  int aquireCode;
  CredHandle credHandle;
  BOOL timeOk;
  SYSTEMTIME sysTime;

  aquireCode = AcquireCredentialsHandle(
          NULL,
          "Kerberos",
          SECPKG_CRED_OUTBOUND,
          NULL,
          NULL,
          NULL,
          NULL,
          &credHandle,
          &expiry);

  printf("result = %d\n", aquireCode);
  printf("upper = %d (%X)\n", expiry.HighPart, expiry.HighPart);
  printf("lower = %d (%X)\n", expiry.LowPart, expiry.LowPart);

  timeOk = FileTimeToSystemTime((FILETIME*)&expiry, &sysTime);
  printf("time covert ok = %d\n", timeOk);
  printf("%4d/%02d/%02d %02d:%02d:%02d\n", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond);
}

On my system, this prints:

result = 0
upper = 2147483530 (7FFFFF8A)
lower = -1488801793 (A742AFFF)
time covert ok = 1
30828/09/13 12:48:05

If it's not a FILETIME, what is it?

Lachlan
  • 3,744
  • 2
  • 26
  • 29
  • Did you ever figure this out? I'm seeing exactly the same thing and the web seems silent on the matter. – alexh Dec 24 '12 at 14:27
  • No, I never got to the bottom of it. Luckily I didn't end up needing to know the expiry for the problem I was solving. – Lachlan Jan 07 '13 at 22:04
  • 2
    Attention, your code contains a bug. ACH returns a time object in local time but FileTimeToSystemTime requires a UTC time object to convert. Use LocalTimeToFileTime in the first place. Btw, I have the same stupid date. Must be some MS idioticy. Digest or NTLM deliver completely different dates. I would say that this expiry is absolutely useless. – Michael-O Aug 19 '14 at 16:31

0 Answers0