Skip to content

Commit

Permalink
Merge 25771d1 into 05d4af1
Browse files Browse the repository at this point in the history
  • Loading branch information
mkszuba committed Jun 9, 2017
2 parents 05d4af1 + 25771d1 commit af7749b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
24 changes: 24 additions & 0 deletions lib/facter/account_names.rb
@@ -0,0 +1,24 @@
# Custom fact that shows the current name of the Administrator and
# Guest accounts based on well-known SID's.
#
# http://support.microsoft.com/kb/243330
#
require 'puppet'

Facter.add(:account_names) do
confine osfamily: :windows

setcode do
account_names = {}

Puppet::Type.type('user').instances.find_all do |user|
user_values = user.retrieve
# Check for the well-known admin SID.
account_names['Administrator'] = user.name if user_values[user.property(:uid)] =~ /^S-1-5-21.*-500$/
# Check for the well-known guest SID.
account_names['Guest'] = user.name if user_values[user.property(:uid)] =~ /^S-1-5-21.*-501$/
end

account_names
end
end
8 changes: 4 additions & 4 deletions manifests/package.pp
Expand Up @@ -97,8 +97,8 @@
file { "${msoffice::params::temp_dir}\\office_config.ini":
content => template('msoffice/setup.ini.erb'),
mode => '0755',
owner => 'Administrator',
group => 'Administrators',
owner => $facts['account_names']['Administrator'],
group => 'S-1-5-32-544',
}

exec { 'install-office':
Expand All @@ -114,8 +114,8 @@
file { "${msoffice::params::temp_dir}\\office_config.xml":
content => template('msoffice/config.erb'),
mode => '0755',
owner => 'Administrator',
group => 'Administrators',
owner => $facts['account_names']['Administrator'],
group => 'S-1-5-32-544',
}

exec { 'install-office':
Expand Down

0 comments on commit af7749b

Please sign in to comment.