From 452fa826ed1ebeb1317b8c2c4c508350e2fde27f Mon Sep 17 00:00:00 2001 From: Patrick Braun Date: Thu, 18 Sep 2025 15:08:49 +0200 Subject: [PATCH] Update credential validation for domain context Attempting to authenticate against the local machine when in a domain context fails. Authenticate against a domain controller instead. This addresses issue hashicorp#11945 with the suggested fix by onpubcom. --- plugins/hosts/windows/scripts/check_credentials.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/hosts/windows/scripts/check_credentials.ps1 b/plugins/hosts/windows/scripts/check_credentials.ps1 index a9a3f699049..4598e72a052 100644 --- a/plugins/hosts/windows/scripts/check_credentials.ps1 +++ b/plugins/hosts/windows/scripts/check_credentials.ps1 @@ -1,6 +1,6 @@ -# Copyright (c) HashiCorp, Inc. -# SPDX-License-Identifier: BUSL-1.1 - +# Copyright (c) HashiCorp, Inc. +# SPDX-License-Identifier: BUSL-1.1 + Param( [Parameter(Mandatory=$true)] [string]$username, @@ -20,7 +20,7 @@ if ( $DSContext.ValidateCredentials( $username, $password ) ) { $DSContext = New-Object System.DirectoryServices.AccountManagement.PrincipalContext( [System.DirectoryServices.AccountManagement.ContextType]::Domain, - $env:COMPUTERNAME + $env:USERDOMAIN ) if ( $DSContext.ValidateCredentials( $username, $password ) ) { exit 0 @@ -35,3 +35,4 @@ if ( $DSContext.ValidateCredentials( $username, $password ) ) { } exit 1 +