win_user - use proper error code when failing to validate creds (#60181)

pull/59720/head
Jordan Borean 5 years ago committed by GitHub
parent 92187ae53e
commit 45d0e5994a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- win_user - Get proper error code when failing to validate the user's credentials

@ -73,14 +73,19 @@ namespace Ansible
$env:TMP = $original_tmp
$handle = [IntPtr]::Zero
$logon_res = [Ansible.WinUserPInvoke]::LogonUser($Username, $null, $Password,
$LOGON32_LOGON_NETWORK, $LOGON32_PROVIDER_DEFAULT, [Ref]$handle)
$logon_res = [Ansible.WinUserPInvoke]::LogonUser(
$Username,
$null,
$Password,
$LOGON32_LOGON_NETWORK,
$LOGON32_PROVIDER_DEFAULT,
[Ref]$handle
); $err_code = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
if ($logon_res) {
$valid_credentials = $true
[Ansible.WinUserPInvoke]::CloseHandle($handle) > $null
} else {
$err_code = [System.Runtime.InteropServices.Marshal]::GetLastWin32Error()
# following errors indicate the creds are correct but the user was
# unable to log on for other reasons, which we don't care about
$success_codes = @(

Loading…
Cancel
Save