Ask Your Question
0

Detect User Logged in when running Puppet on Windows

asked 2013-08-12 13:19:38 -0500

louis gravatar image

Hi,

I am trying to set a nuget configuration for every windows developer machine and i need to access the Windows C:\Users\<username> in order to navigate to the file that i want to manage with puppet.

Now since puppet runs under the SYSTEM account i would like to know if it can be possible to retrieve the username (currently logged in) in other to use it as a FACT variable.

When I try it shows me system user rather than the actual user.

Facter.add("user_name") do
  confine :kernel => "Windows"
  setcode do
    Facter::Util::Resolution.exec('c:\Windows ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-12 13:55:34 -0500

GregLarkin gravatar image

This technique is a little more complicated, but maybe you can put the code in a batch file and exec it from your custom fact. Basically, it determines the Windows logged-in username from the owner of the explorer.exe process. I didn't look too hard, so maybe there is a simpler way to do it.

edit flag offensive delete link more

Comments

Interesting. Wondering if there is another way to access windows internals to get this done in a simple way

louis gravatar imagelouis ( 2013-08-12 14:26:50 -0500 )edit

I found this: http://rubyforge.org/projects/win32utils/. I don't see any bindings that are obviously used for accessing current user sessions, but this like will lead you to ...(more)

GregLarkin gravatar imageGregLarkin ( 2013-08-12 14:58:53 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-08-12 13:19:38 -0500

Seen: 390 times

Last updated: Aug 12 '13