terraform-provider-ad icon indicating copy to clipboard operation
terraform-provider-ad copied to clipboard

Update vendored dependency github.com/masterzen/winrm/powershell.go to the latest version

Open Zyava opened this issue 3 years ago • 1 comments

Terraform Version and Provider Version

TF version: 0.14.5 Provider version: 0.4.3 (latest as of time of writing)

Expected Behavior

Non-ASCII characters (german umlauts in my case) in user attributes (first name, last name, etc.) are supported.

Actual Behavior

Non-ASCII characters in generated powershell command has broken, resulting in broken user data in AD.

Steps to Reproduce

  1. Enable Powershell commands logging to be able to examine commands executed by provider:
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription" /v EnableTranscripting /t REG_DWORD /d 1 /f
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription" /v OutputDirectory /t REG_SZ /d "C:\" /f
reg add "HKLM\Software\Policies\Microsoft\Windows\PowerShell\Transcription" /v EnableInvocationHeader /t REG_DWORD /d 1 /f
  1. Try to update an AD user with non-ASCII character in the name.
resource "ad_user" "user" {
... 
  display_name = "Max Möstermann"
  given_name   = "Max"
  surname      = "Möstermann" 
...
}
  1. Find and open powershell transcript file with apply powershell, command in the file will be corrupted:
Set-ADUser -Identity "9ae4c1ff-b104-4422-8021-ccc0c4ac4400" -DisplayName "Max M菃숀¶stermann" -Surname "M菃숀¶stermann" ...
  1. Copy contents of https://github.com/masterzen/winrm/blob/master/powershell.go into local copy of https://github.com/hashicorp/terraform-provider-ad/blob/main/vendor/github.com/masterzen/winrm/powershell.go, build provider from sources, copy it to TF plugins cache directory, etc.

  2. Run plan and apply again, find and open powershell transcript file with apply powershell, command in the file will be NOT corrupted:

Set-ADUser -Identity "9ae4c1ff-b104-4422-8021-ccc0c4ac4400" -DisplayName "Max Möstermann" -Surname "Möstermann" ...

Zyava avatar Aug 16 '21 17:08 Zyava

TF version: 1.0.6 Provider version: 0.4.3

I have the same problem, but with Russian characters (Cyrillic) in the title and department parameters

enb-f avatar Oct 08 '21 11:10 enb-f