From 43c44c6584c069a4be58c43a071fd1ffb45745f5 Mon Sep 17 00:00:00 2001 From: Stuart Preston Date: Wed, 18 Jul 2018 11:52:58 +0100 Subject: FFI.LastError.error always returns 0 if used in the prior exception Signed-off-by: Stuart Preston --- lib/chef/util/windows/net_user.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index 25a413861b..5d0dbf7a53 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -98,13 +98,13 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT) true rescue Chef::Exceptions::Win32APIError => e - # we're only interested in the password failures - if FFI::LastError.error == Win32APIError::ERROR_LOGON_FAILURE + Chef::Log.trace(e) + # we're only interested in the incorrect password failures + if e.to_s =~ /System Error Code: 1326/ return false end # all other exceptions will assume we cannot logon for a different reason Chef::Log.trace("Unable to login with the specified credentials. Assuming the credentials are valid.") - Chef::Log.trace(e) true end -- cgit v1.2.1