I am using NetWkstaUserEnum()
to get the local users name and its domain details.
Till Windows 7 it used to return only the login name and it worked fine. From Windows 8 onwards Microsoft Account was added and for this type of account the API started returning the Microsoft Account name instead of the local login name.
For example it returned username@outlook.com
instead of usern_0000
which is the actual Windows local login name.
I cannot use NetUserEnum()
as it does not return the domain name of the user.
So I need to get the local login name for the given Microsoft Account returned by NetWkstaUserEnum()
API.
Any help will be appreciated.
Finally I was able to locate a way to get the Windows username for the given Microsoft Account.It uses
NetUserGetInfo()
to get the Microsoft Account name for the given username.Code Snippet: