Platform SDK: Get domain name
-
I need to get the domain name for the currently logged on user. ::GetUserName gets me the user name, but how do I get the domain name for that user? Thanks!
-
I need to get the domain name for the currently logged on user. ::GetUserName gets me the user name, but how do I get the domain name for that user? Thanks!
With, Win32_LogonSession you will get 'LogonId' use this logonId to query the Win32_LoggedOnUser. After querying 'Win32_LoggedOnUser' you will get all the fields, like - Domain, Name etc Supriya
-
I need to get the domain name for the currently logged on user. ::GetUserName gets me the user name, but how do I get the domain name for that user? Thanks!
Use
NetWkstaUserGetInfo
[^] and retrieve level 1 information, as below. Requires Windows NT 3.1, 2000, XP, Vista.#include <Windows.h>
#include <lm.h>std::wstring GetDomainName()
{
WKSTA_USER_INFO_1* workstationInfo;
const NET_API_STATUS status = NetWkstaUserGetInfo(NULL, 1, (LPBYTE*)&workstationInfo);
if (status == NERR_Success)
{
return workstationInfo->wkui1_logon_domain;
NetApiBufferFree((LPBYTE*)&workstationInfo);
}
return std::wstring();
} -
I need to get the domain name for the currently logged on user. ::GetUserName gets me the user name, but how do I get the domain name for that user? Thanks!