nvpapworth
Contributor
Contributor

Setting SAML Authenticator in Connection Server


I'm attempting to add a newly created SAML Authenticator to a Connection Server using a Powershell script, a snippet of which is below.

If I try and set either the "samlAuthenticator" single value or the "samlAuthenticators" list (with a single value), I get an error "Invalid argument type for this member". I'm using a SAMLAuthenticatorId value, which is the value as returned from when the SAML Authenticator is created.

I don't know if I need to manipulate the id value or use as is, or also if I somehow need to "cast" the value set in the MapEntry.value.

A secondary question here is how I represent an array of values when I'm attempting to set samlAuthenticators, if I just wrap the values in curly brackets, and comma separate the values within it - I cannot find any examples of using an array of things in a MapEntry.value.

Any ideas of what I am doing wrong, or does anyone have examples of working code in this area ? I'm using version 7.8 of Horizon View.

$hvServer = Connect-HVServer -Server hv-connection.example.com -User domainadminuser@example.com -Password "password" -Domain example.com
$Global:hvServices = $hvServer.ExtensionData
$csService = New-Object VMware.Hv.ConnectionServerService
$csList = $csService.ConnectionServer_List($hvServices)

$csId = $csList[0].id

$update1 = New-Object VMware.Hv.MapEntry
$update1.key = 'authentication.samlConfig.samlSupport'
$update1.value = 'ENABLED'
*** or ***
$update1.value = 'MULTI_ENABLED'

$update2 = New-Object VMware.Hv.MapEntry
$update2.key = 'authentication.samlConfig.samlAuthenticator'
$update2.value = 'SAMLAuthenticator/ODxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxY0/MzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxVl'

*** or ***

$update2 = New-Object VMware.Hv.MapEntry
$update2.key = 'authentication.samlConfig.samlAuthenticators'
$update2.value = '{SAMLAuthenticator/ODxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxY0/MzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxVl}'

$updates = @()
$updates += $update1
$updates += $update2

$hvServices.ConnectionServer.ConnectionServer_Update($csId, $updates)

Errors :

Exception calling "ConnectionServer_Update" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidType
ErrorMessage : Invalid argument type for this member.
ParameterName : authentication.samlConfig.samlAuthenticator
ExpectedType : SAMLAuthenticatorId"
At C:\Users\xxx\samlupdate2.ps1:65 char:1
+ $hvServices.ConnectionServer.ConnectionServer_Update($csId, $updates)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException

Exception calling "ConnectionServer_Update" with "2" argument(s): "ExceptionType : VMware.Hv.InvalidType
ErrorMessage : Invalid argument type for this member.
ParameterName : authentication.samlConfig.samlAuthenticators
ExpectedType : ArrayOfSAMLAuthenticatorId"
At C:\Users\xxx\samlupdate2.ps1:65 char:1
+ $hvServices.ConnectionServer.ConnectionServer_Update($csId, $updates)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : VimException

 

Reply
0 Kudos