Get full username for new username
When using NetUserAdd, the user will be created on the local computer or as a domain account, depending on the role of the server on which you used this feature.
I want to get the full username (LOCALCOMPUTER \ USERNAME or DOMAIN \ USERNAME) in order to use it remotely.
Is there a function for this?
a source to share
Caveat: I haven't tested the solution. You can call NetGetJoinInformation to see if the device belongs to the domain and NetServerGetInfo if the code is running on a DC. After this test, you can get the machine name (GetComputerName) and domain name (NetWkstaGetInfo) and whatever you need.
Be careful when doing this in a cluster.
a source to share
I'm sure I'm missing something, but you can't use GetUserNameEx
and pass what you want EXTENDEND_NAME_FORMAT
? I believe there NameSamCompatible
should be a desired format.
You will return either to MachineName\UserName
orDomainName\UserName
a source to share