Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Re: Get the Current Domain Name in Windows
Berger, Daniel
4/25/2005 6:43:00 PM
> -----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 Windows
>
>
> Hello,
>
> 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.
<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-...
wmi/win32_computersystem.asp for more info.
Regards,
Dan
1 Answer
Brian Takita
4/25/2005 7:28:00 PM
0
Thank you Dan,
This works wonderfully.
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Re: Get the Current Domain Name in Windows
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password