diff options
-rw-r--r-- | lib/chef/util/windows/logon_session.rb | 7 | ||||
-rw-r--r-- | lib/chef/win32/security.rb | 3 |
2 files changed, 4 insertions, 6 deletions
diff --git a/lib/chef/util/windows/logon_session.rb b/lib/chef/util/windows/logon_session.rb index 912a603865..afe58ae4f9 100644 --- a/lib/chef/util/windows/logon_session.rb +++ b/lib/chef/util/windows/logon_session.rb @@ -48,11 +48,8 @@ class Chef password = wstring(original_password) domain = wstring(original_domain) - if authentication == :remote - status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token) - elsif authentication == :local - status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NETWORK, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token) - end + logon_type = (authentication == :local) ? (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NETWORK) : (Chef::ReservedNames::Win32::API::Security::LOGON32_LOGON_NEW_CREDENTIALS) + status = Chef::ReservedNames::Win32::API::Security.LogonUserW(username, domain, password, logon_type, Chef::ReservedNames::Win32::API::Security::LOGON32_PROVIDER_DEFAULT, token) if !status last_error = FFI::LastError.error diff --git a/lib/chef/win32/security.rb b/lib/chef/win32/security.rb index c658c8f70f..63b626b1d7 100644 --- a/lib/chef/win32/security.rb +++ b/lib/chef/win32/security.rb @@ -350,7 +350,8 @@ class Chef end info_ptr = FFI::MemoryPointer.new(:pointer) token_info_pointer = TOKEN_ELEVATION_TYPE.new info_ptr - unless GetTokenInformation(token.handle.handle, :TokenElevationType, token_info_pointer, 4, token_result_size) + token_info_length = 4 + unless GetTokenInformation(token.handle.handle, :TokenElevationType, token_info_pointer, token_info_length, token_result_size) Chef::ReservedNames::Win32::Error.raise! end token_info_pointer[:ElevationType] |