The web page is nasty to navigate, I think they make it hard so people decide to give up and go get a beer instead of logging a job :)
Anyway, one of the fields on the page requires the full name of the person logging the job. It's trivial to grab the username of the logged on user:
1 puts ENV['USERNAME']
However, I wasn't sure of the easiest way to grab the user's full name. There are a few packages out there, for example the sys-admin gem. It didn't work though, I dug around in the source and it hardcodes a cimv2 path, no good.
Seeing this is a quick hack running on windows for windows, rah rah rah, might as well boogey with it.
Enter ADSI.
The following interrogates our AD and grabs what I want. Too easy.
1 require 'win32ole'
2 puts WIN32OLE.connect("WinNT://your.ad.box.sa.gov.au/#{ENV['USERNAME']}").FullName
2 puts WIN32OLE.connect("WinNT://your.ad.box.sa.gov.au/#{ENV['USERNAME']}").FullName
No comments:
Post a Comment