lib/win32/security/sid.rb in win32-security-0.3.3 vs lib/win32/security/sid.rb in win32-security-0.4.0

- old
+ new

@@ -225,15 +225,15 @@ end end ordinal_val = account ? account[0].ord : nil - sid = FFI::MemoryPointer.new(:uchar, 260) + sid = FFI::MemoryPointer.new(:uchar, 1024) sid_size = FFI::MemoryPointer.new(:ulong) sid_size.write_ulong(sid.size) - domain = FFI::MemoryPointer.new(:uchar, 260) + domain = FFI::MemoryPointer.new(:uchar, 1024) domain_size = FFI::MemoryPointer.new(:ulong) domain_size.write_ulong(domain.size) use_ptr = FFI::MemoryPointer.new(:ulong) @@ -252,11 +252,11 @@ end elsif ordinal_val < 10 # Assume it's a binary SID. account_ptr = FFI::MemoryPointer.from_string(account) bool = LookupAccountSid( - host, + host.encode('UTF-16LE'), account_ptr, sid, sid_size, domain, domain_size, @@ -268,12 +268,12 @@ end account_ptr.free else bool = LookupAccountName( - host, - account, + host.encode('UTF-16LE'), + account.encode('UTF-16LE'), sid, sid_size, domain, domain_size, use_ptr @@ -285,21 +285,22 @@ # The arguments are flipped depending on which path we took if ordinal_val.nil? length = GetLengthSid(token_info) @sid = token_info.read_string(length) - @account = sid.read_string(sid.size).strip + @account = sid.read_bytes(sid.size).wstrip elsif ordinal_val < 10 @sid = account - @account = sid.read_string(sid.size).strip + @account = sid.read_bytes(sid.size).wstrip else length = GetLengthSid(sid) - @sid = sid.read_string(length) + @sid = sid.read_bytes(length) @account = account end + @host = host - @domain = domain.read_string + @domain = domain.read_bytes(domain.size).wstrip @account_type = get_account_type(use_ptr.read_ulong) end # Synonym for SID.new.