tags:

views:

74

answers:

1

Hi,

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?

Thanks

+1  A: 

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.

Giulio Vian