0
Not a bug

PowerShell Connector handling of DN.multi attributes where there is a single value

Boyd Bostock 2 years ago in PowerShell connector • updated by anonymous 2 years ago 4

The PowerShell Connector treats DN.multi attributes with a single value differently to how it treats string.multi attributes with a single value. This can be overcome in the script however unnecessarily complicates import the script.

Error if handled the same as a string.multi (appears to take first char rather than first array entry):

DN.multi Error.txt

Script that will handle the single value: StudentParentRelationshipsImport.ps1

DN.multi attribute: ParentRelationshipDNs

String.multi attribute: ParentIDLIST


Identity Broker: v5.0.5


Affected Versions:
Fixed by Version:

Answer

Answer
Not a bug

Hi Boyd,

This appears to be a peculiarity with PowerShell.

$array = @('A')
$array.GetType() # Object[]
$sort = $array | Sort
$sort.GetType() # String
$sort = @($array | Sort)
$sort.GetType() # Object[]

Please make sure that you force your value into an array before assigning to multi-valued fields.

Under review

Hi Boyd,

Are you able to supply a minimum reproducible example? The following two methods for adding a single value to a multi-value distinguished name should work.

Import Script:

$entity = $entities.Create()
$entity['ID'] = 10002
$dns = @()
$dns += 'CN=1'
$entity['A'] = $dns
$entity['B'] = @('CN=2')
$entity.Commit();

Schema:

New-Field 'ID' 'string' $true $false $true;
New-Field 'A' 'dn.multi' $false $false $false;
New-Field 'B' 'dn.multi' $false $false $false;

Hi Boyd,


Any update on this issue?

Hi Curtis

I have been experimenting and found it is cased by performing the Sort (eg $Attribute | Sort) before the import and that it is not limited to DNs. I suspect the Sort is changing the array object somehow. As I need to sort the list and ensure it is unique I process it before importing to the $entity.

Boyd

Answer
Not a bug

Hi Boyd,

This appears to be a peculiarity with PowerShell.

$array = @('A')
$array.GetType() # Object[]
$sort = $array | Sort
$sort.GetType() # String
$sort = @($array | Sort)
$sort.GetType() # Object[]

Please make sure that you force your value into an array before assigning to multi-valued fields.