I am trying to obtain the name of the LogonDomain for the currently logged on user. I need this information to be able to determine if the user was logged in using a MicrosoftAccount, AzureAD or standard Windows Active Directory Domain.

When using the Sysinternals BGInfo.exe utility, when on a Windows active directoy I get the name of the Domain, when running for a user logged in using a Microsoft account it returns "MicrosoftAccount". This is what I am expecting.

To this I am trying to use the WTSQuerySessionInformation with "WTSConfigInfo" for the WTS_INFO_CLASS parameter as follows:

DWORD dwSessionID;
LPSTR ppBuffer = NULL;
DWORD dwBytesReturned = 0;
WTS_INFO_CLASS wtsci = WTSConfigInfo;

if (!ProcessIdToSessionId(GetCurrentProcessId(), &dwSessionID))

if (WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, dwSessionID, wtsci, &ppBuffer, &dwBytesReturned))

if (dwBytesReturned > 0)
pInfo = (WTSCONFIGINFO*)ppBuffer;
OutputDebugStringX("LogonUserName = %s", pInfo->LogonUserName);
OutputDebugStringX("LogonDomain = %s", pInfo->LogonDomain);


The code executes without error with 848 bytes returned. The problem is that besides the pInfo->Version parameter that returns "1", everything else is blank.

Anyone have any idea why this is not working or if there is another way to determine who validated the logged on user?