Skip to content
This repository was archived by the owner on Jun 12, 2023. It is now read-only.
This repository was archived by the owner on Jun 12, 2023. It is now read-only.

Add-AdfsWebApiApplication command not working in Powershell 7  #19

@thomaslazar

Description

@thomaslazar

Issue originally reported here. Was told to move it to this repository.

Steps to reproduce

  1. Windows System with ADFS Installed
  2. Have following AdfsAccessControlPolicy in place
Get-AdfsAccessControlPolicy -name "Permit specific claim"

Name           : Permit specific claim
Identifier     : Permitspecificclaim
IsBuiltIn      : False
RpUsageCount   : 4
LastUpdateTime : 25.03.2019 15:40:00
Description    :
PolicyMetadata : RequireFreshAuthentication:False
                 IssuanceAuthorizationRules:
                 {
                   Permit users
                     with <ClaimsParameter_0> in the request
                 }
                 ParameterDescription:
                 {
                   <ClaimsParameter_0>: Specify condition with ClaimType, Operator and Value using hashtable.
                 }
  1. Run script from following Gist Setup-AdfsApplicationGroup.ps1

Specifically this bit is the problem.

$acl = @{
    ClaimsParameter_0 = @{ ClaimType = 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role'; Operator = 'Contains'; Value = $CustomerGroup }
}

Add-AdfsWebApiApplication -ApplicationGroupIdentifier $CustomerId -Identifier "$CustomerId" -Name "$CustomerId - Web Application" -AccessControlPolicyName "Permit specific claim" -AccessControlPolicyParameters $acl -TokenLifetime 15

Expected behavior

Should run and create an AdfsWebApplication

Actual behavior

Add-AdfsWebApiApplication: ADMIN0144: SpecificClaimCondition and SpecificClaimException parameter 'ClaimsParameter_0' should be assigned through a hashtable that specifies ClaimType, Operator and Value. If multiple conditions are desired, use an array of hashtables.

Additional information

I used dotPeak to look into Microsoft.IdentityServer.dll. The problem seems to be the following check inside the ParameterInterface.cs AssignSpecificClaimParemeterFromPSHInput method , which is not working in PowerShell 7 but is working in PowerShell 5.1

if (!(value is Hashtable hashtable))
  throw new InvalidDataException(Microsoft.IdentityServer.SR.GetString("ADMIN0144", (object) specific.Label));

The content of the variable value is the content that got passed into the AccessControlPolicyParameters parameter of the Add-AdfsWebApiApplication command.

It does not matter what you put into the AccessControlPolicyParameters parameter. It always triggers this check and throws the exception.

Environment data

PS C:\Temp> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.0.0
PSEdition                      Core
GitCommitId                    7.0.0
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions