New-PSUEndpoint - Self referencing loop detected

Hey

Trying to setup a PSU Endpoint, so trying out something simple first

New-PSUEndpoint -Url "/locked/:Identity" -Method 'GET' -Endpoint { 
    Get-ADUser -Identity $Identity
}

I would expect

Invoke-RestMethod https://universaldashboard.company.com/locked/testaccount

to return my test active directory account, However it returns this

Invoke-RestMethod: Self referencing loop detected for property 'AccountDomainSid' with type 'System.Security.Principal.SecurityIdentifier'. Path '[0].SID.AccountDomainSid'.

If i throw in a username for an account that doesn’t exist it returns that the account doesn’t exist, but looking up a real account just errors.

Am i missing something obvious here?

Thanks
Scott

hey, on what version on psu you on ?

hey

using 1.3.0

The issue is, that the user’s SID is stored as a System.Security.Principal.SecurityIdentifier object. This class defines a property AccountDomainSid which is a SecurityIdentifier again and again has the property AccountDomainSid.

$s = New-Object System.Security.Principal.SecurityIdentifier('S-1-5-21-2574500967-3820011325-2890284680-1000')
$s.AccountDomainSid.AccountDomainSid.AccountDomainSid.AccountDomainSid

To work-around this, you can create a pscustomobject with the properties you need that don’t create this recursion issue.

@adam, can we set the serialization depth somewhere?

I’ve logged an issue for this. We should be able to fix that.

You can work around it by using ConvertTo-Json directly and specifying the depth that way.

maybe add a setting to the environment. we also need custom depth