<snip>
Here's an alternative approach using OLE + WMI:
require "win32ole"
require "socket"
host = ARGV[0] || Socket.gethostname
cs = "winmgmts:{impersonationLevel=impersonate}!"
cs << "//#{host}/root/cimv2"
wmi = WIN32OLE.connect(cs)
wmi.InstancesOf("Win32_ComputerSystem").each{ |obj|
p obj.domain
p obj.username
}
See
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/
wmi/win32_computersystem.asp for more info.
Regards,
Dan
···
-----Original Message-----
From: Brian Takita [mailto:brian.takita@gmail.com]
Sent: Monday, April 25, 2005 11:29 AM
To: ruby-talk ML
Subject: Get the Current Domain Name in WindowsHello,
I am trying to find out the domain name for the current user.
This is my first endeavor into dl/win32 and I am having no
luck getting the data.