lib/win32/security/sid.rb in win32-security-0.3.2 vs lib/win32/security/sid.rb in win32-security-0.3.3
- old
+ new
@@ -12,11 +12,11 @@
include Windows::Security::Functions
include Windows::Security::Structs
extend Windows::Security::Functions
# The version of the Win32::Security::SID class.
- VERSION = '0.2.2'
+ VERSION = '0.2.3'
# Some constant SID's for your convenience, in string format.
# See http://support.microsoft.com/kb/243330 for details.
Null = 'S-1-0'
@@ -223,16 +223,11 @@
ensure
CloseHandle(token) if token
end
end
- if account
- ordinal_val = account[0]
- ordinal_val = ordinal_val.ord if RUBY_VERSION.to_f >= 1.9
- else
- ordinal_val = nil
- end
+ ordinal_val = account ? account[0].ord : nil
sid = FFI::MemoryPointer.new(:uchar, 260)
sid_size = FFI::MemoryPointer.new(:ulong)
sid_size.write_ulong(sid.size)
@@ -288,10 +283,11 @@
end
end
# The arguments are flipped depending on which path we took
if ordinal_val.nil?
- @sid = token_info.read_string
+ length = GetLengthSid(token_info)
+ @sid = token_info.read_string(length)
@account = sid.read_string(sid.size).strip
elsif ordinal_val < 10
@sid = account
@account = sid.read_string(sid.size).strip
else