diff options
author | Stuart Preston <stuart@chef.io> | 2018-07-25 10:04:17 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-25 10:04:17 +0100 |
commit | c85f28481a7ee6308e4dc3e29ad26f05c38c9432 (patch) | |
tree | 75fdf2f0d2cb7b255a08c30196318425b2403cb6 /lib/chef/util | |
parent | 98762283604d272c39c9993dd407648f52db5c96 (diff) | |
download | chef-c85f28481a7ee6308e4dc3e29ad26f05c38c9432.tar.gz |
Assume credentials supplied are still valid if they cannot be validated due to a Windows account restriction (#7416)
Signed-off-by: Stuart Preston <stuart@chef.io>
Diffstat (limited to 'lib/chef/util')
-rw-r--r-- | lib/chef/util/windows/net_user.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index 9231afe46f..5d0dbf7a53 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -29,6 +29,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows NetUser = Chef::ReservedNames::Win32::NetUser Security = Chef::ReservedNames::Win32::Security + Win32APIError = Chef::ReservedNames::Win32::API::Error USER_INFO_3_TRANSFORM = { name: :usri3_name, @@ -96,8 +97,15 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows token = Security.logon_user(@username, nil, passwd, LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT) true - rescue Chef::Exceptions::Win32APIError - false + rescue Chef::Exceptions::Win32APIError => e + 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.") + true end def get_info |