Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters