Method: Puppet::Util::Windows::SID.sid_to_name
- Defined in:
- lib/puppet/util/windows/sid.rb
.sid_to_name(value) ⇒ Object
Convert a SID string, e.g. “S-1-5-32-544” to a name, e.g. ‘BUILTINAdministrators’. Returns nil if an account for that SID does not exist.
141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/puppet/util/windows/sid.rb', line 141 def sid_to_name(value) sid_bytes = [] begin string_to_sid_ptr(value) do |ptr| sid_bytes = ptr.read_array_of_uchar(get_length_sid(ptr)) end rescue Puppet::Util::Windows::Error => e raise if e.code != ERROR_INVALID_SID_STRUCTURE end Principal.lookup_account_sid(sid_bytes).domain_account rescue nil end |