Link to home
Start Free TrialLog in
Avatar of SpprtMechanic
SpprtMechanic

asked on

Retrieving Domain of Logged in user

After countless searching I still can't find the answer.

The problem is this. I am writing a VB program that needs to know who the user is that is logged into windows. I can get the username just fine using the Windows API GetUserNameA, however I need the domain name of the account also. The GetUserNameA only returns the Username of the account. The domain is necessary part so the program can run properly since it will connect to a SQL database using Windows NT authentication.

Only requirement, can not use Windows Scripting Host, since the exe will be ran from a network directory I can not take the chance on whether or not the machine has WSH installed (or some other non common DLL).

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of vinnyd79
vinnyd79

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SpprtMechanic
SpprtMechanic

ASKER

Thanks Vinny, that worked wonderful. One quick question, where can I find what other values are available in with the Environ() function? Microsoft's web site only discusses it in general terms and gives no specifics about it.

Thanks.
Avatar of Richie_Simonetti
This will loop through the available variables and their values:

Private Sub Command1_Click()
For x = 1 To 80
MsgBox Environ(x)
Next x
End Sub