Method: Puppet::Util::Windows::SID#sid_ptr_to_string
- Defined in:
- lib/vendor/puppet/util/windows/sid.rb
#sid_ptr_to_string(psid) ⇒ Object
Convert a SID pointer to a SID string, e.g. “S-1-5-32-544”.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/vendor/puppet/util/windows/sid.rb', line 50 def sid_ptr_to_string(psid) sid_buf = 0.chr * 256 str_ptr = 0.chr * 4 raise Puppet::Util::Windows::Error.new("Invalid SID") unless IsValidSid(psid) raise Puppet::Util::Windows::Error.new("Failed to convert binary SID") unless ConvertSidToStringSid(psid, str_ptr) begin strncpy(sid_buf, str_ptr.unpack('L')[0], sid_buf.size - 1) sid_buf[sid_buf.size - 1] = 0.chr return sid_buf.strip ensure LocalFree(str_ptr.unpack('L')[0]) end end |