Forum Discussion

simonaferrara's avatar
Frequent Contributor
2 years ago

Retrieve the domain of the logged-in user

Hi all,


I've got the need to retrieve the domain of the user logged-in within the machine, that is: not the domain of the machine, but the domain of the user, that could be the HostName if the user is a local one, of a specific domain if the user belongs to a domain.


I've found these properties but they don't match with the need:

- Sys.Domain (it is the domain of the machine)

- Sys.UserName (it is the username, but I've been not able to retrieve information about its domain)


Have you got any suggestion?




  • Try the following:


    sUserDomain = aqEnvironment.GetEnvironmentVariable("USERDOMAIN")