I think the AD stuff is only for use on a domain controller (?).
Here is an extract of some code I use for login time (sorry it is editted without compile if it has syntax errors):
#include <Ntsecapi.h>
BOOL GetLogonLUID (LUID *pLuid)
{
BOOL bSuccess = FALSE;
HANDLE hThread = NULL;
TOKEN_STATISTICS ts = {0};
DWORD cbReturnLength = sizeof(TOKEN_STATISTICS);
bSuccess = OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &hThread);
if (bSuccess)
{
bSuccess = GetTokenInformation (hThread, TokenStatistics, &ts, sizeof(TOKEN_STATISTICS), &cbReturnLength);
if (bSuccess)
*pLuid = ts.AuthenticationId;
}
if (hThread)
CloseHandle (hThread);
return bSuccess;
}
SYSTEMTIME& GetLoginTime()
{
static SYSTEMTIME st = {0};
FILETIME ft = {0};
LUID LogonLuid = {0};
PSECURITY_LOGON_SESSION_DATA pLogonSessionData = NULL;
GetLogonLUID (&LogonLuid);
NTSTATUS ntStatus = LsaGetLogonSessionData (&LogonLuid, &pLogonSessionData);
if (ntStatus == 0)
{
if (pLogonSessionData->LogonTime.QuadPart)
{
FileTimeToLocalFileTime ((const FILETIME *)&pLogonSessionData->LogonTime, &ft);
FileTimeToSystemTime (&ft, &st);
}
}
if (pLogonSessionData)
LsaFreeReturnBuffer(pLogonSessionData);
return st;
}