How to get username in Windows domain from service using Ruby? -


i need name of domain user in windows.

here ways tried name, return domain name:

1.

... env['username'] # or env['username'] or env['userid'] ... 

2.

... require 'etc' puts etc.getlogin ... 

3.

... require 'dl/win32'  def get_user_name   api = win32api.new(     'advapi32.dll',     'getusername',     'pp',     'i'   )    buf = "\0" * 512   len = [512].pack('l')   api.call(buf,len)    buf[0..(len.unpack('l')[0])] end ... 

4.

this way return string "system":

... require 'win32ole' network=win32ole.new("wscript.network") puts network.username ...  

how can username or pair domain\username?

can't run system commands , store them in variable.

u = `whoami /user`  

now u has user information processing, isnt?


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -