lib/win32/security/sid.rb in win32-security-0.1.1 vs lib/win32/security/sid.rb in win32-security-0.1.2
- old
+ new
@@ -23,11 +23,11 @@
# Error class typically raised if any of the SID methods fail
class Error < StandardError; end
# The version of the Win32::Security::SID class.
- VERSION = '0.1.1'
+ VERSION = '0.1.2'
# Some constant SID's for your convenience, in string format.
# See http://support.microsoft.com/kb/243330 for details.
Null = 'S-1-0'
@@ -106,11 +106,15 @@
unless ConvertStringSidToSid(string_addr, sid_buf)
raise Error, get_last_error
end
- sid_buf.strip
+ if RUBY_VERSION.to_f < 1.9
+ sid_buf.strip
+ else
+ sid_buf.force_encoding('ASCII-8BIT').strip
+ end
end
# Creates a new SID with +authority+ and up to 8 +subauthorities+,
# and returns new Win32::Security::SID object.
#
@@ -180,13 +184,15 @@
domain_buf = 0.chr * 80
domain_cch = [domain_buf.size].pack('L')
sid_name_use = 0.chr * 4
+ ordinal_val = account[0]
+ ordinal_val = ordinal_val.ord if RUBY_VERSION.to_f >= 1.9
# If characters in the 0-10 range, assume it's a binary SID.
- if account[0] < 10
+ if ordinal_val < 10
bool = LookupAccountSid(
host,
[account].pack('p*').unpack('L')[0],
sid,
sid_cb,
@@ -209,10 +215,10 @@
unless bool
raise Error, get_last_error
end
# The arguments are flipped if the account argument is binary
- if account[0] < 10
+ if ordinal_val < 10
@sid = account
@account = sid.strip
else
@sid = sid.strip
@account = account