win_user - use proper error code when failing to validate creds (#60181)
This commit is contained in:
parent
92187ae53e
commit
45d0e5994a
2 changed files with 10 additions and 3 deletions
2
changelogs/fragments/win_user-logon-err.yaml
Normal file
2
changelogs/fragments/win_user-logon-err.yaml
Normal file
|
@ -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…
Reference in a new issue