diff options
author | nimisha <nimisha.sharad@msystechnologies.com> | 2017-12-18 17:44:15 +0530 |
---|---|---|
committer | nimisha <nimisha.sharad@msystechnologies.com> | 2018-01-24 15:00:37 +0530 |
commit | cc9766bd0a98b733eef3e9d40f3eac85a25f7e93 (patch) | |
tree | 5430925a36cbf05ed7949439a1e5686beeb1ea01 /lib/chef/util/windows | |
parent | 9382e77576921af4dd22de00bf5537e55ed60ac1 (diff) | |
download | chef-cc9766bd0a98b733eef3e9d40f3eac85a25f7e93.tar.gz |
Brought back Chef::Win32::Security functional test for running as a non admin user
Signed-off-by: nimisha <nimisha.sharad@msystechnologies.com>
Diffstat (limited to 'lib/chef/util/windows')
-rw-r--r-- | lib/chef/util/windows/logon_session.rb | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/chef/util/windows/logon_session.rb b/lib/chef/util/windows/logon_session.rb index ef80b113b1..5a126f0c4a 100644 --- a/lib/chef/util/windows/logon_session.rb +++ b/lib/chef/util/windows/logon_session.rb @@ -25,7 +25,7 @@ class Chef class LogonSession include Chef::Mixin::WideString - def initialize(username, password, domain = nil) + def initialize(username, password, domain = nil, logon_type) if username.nil? || password.nil? raise ArgumentError, "The logon session must be initialize with non-nil user name and password parameters" end @@ -33,6 +33,7 @@ class Chef @original_username = username @original_password = password @original_domain = domain + @logon_type = logon_type @token = FFI::Buffer.new(:pointer) @session_opened = false @impersonating = false @@ -47,7 +48,11 @@ class Chef password = wstring(original_password) domain = wstring(original_domain) - 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) + if logon_type == :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 logon_type == :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 if !status last_error = FFI::LastError.error @@ -110,6 +115,7 @@ class Chef attr_reader :original_username attr_reader :original_password attr_reader :original_domain + attr_reader :logon_type attr_reader :token attr_reader :session_opened |