Reputation: 1290
When using NetUserAdd the user will be created on the local computer or as a domain account depending the role of the server where you used this function.
I want to retrieve the complete username (LOCALCOMPUTER\USERNAME or DOMAIN\USERNAME) to use it remotely.
Is there a function to do this?
Upvotes: 1
Views: 211
Reputation: 29519
I'm sure I'm missing something, but can't you use GetUserNameEx
and pass in the desired EXTENDEND_NAME_FORMAT
? I believe NameSamCompatible
should be the format you desire.
You'll get back either MachineName\UserName
or DomainName\UserName
Upvotes: 1
Reputation: 8343
Caveat: I haven't checked the solution. You may call NetGetJoinInformation to know if the machine belongs to a domain and NetServerGetInfo if the code is running on a DC. After those test you may get the machine name (GetComputerName) and domain name (NetWkstaGetInfo) and whatever you need.
Be careful if you are doing this on a cluster.
Upvotes: 2