Update:
I tried creating the policy with just the middle name transformation and it didn't take it. I did not like my Regex value of "..*" Not sure why. I am trying to find another transformation method that works.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello,
I am having issues getting my custom policy to work in PowerShell. I am trying to make two separate claim transformations for a SAML application. One is trying to strip all the leading zeros from the beginning of the SamAccountName and the other is removing the middle initial in the givenname field. My code is posted below. If anyone has any suggestions that would be great.
New-AzureADPolicy -Definition @('
{"ClaimsMappingPolicy":
{
"Version":1,"IncludeBasicClaimSet":"false",
"ClaimsSchema":[{"Source":"user","ID":"givenname"},
{"Source":"transformation","ID":"RemoveInitial","TransformationId":"RemoveTheInitial","SamlClaimType":"FIRST_NAME","JwtClaimType":"FIRST_NAME"},
{"Source":"user","ID":"surname","SamlClaimType":"LAST_NAME","JwtClaimType":"LAST_NAME"},
{"Source": "user","ID":"mail","SamlClaimType":"EMAIL","JwtClaimType":"EMAIL"},
{"Source":"user","ID":"onpremisessamaccountname"},
{"Source":"transformation","ID":"RemoveZeros","TransformationId":"RemoveTheZeros","SamlClaimType":"USER_ID","JwtClaimType":"USER_ID"}],
"ClaimsTransformations":[{"ID":"RemoveTheInitial","TransformationMethod":"RegexReplace","InputClaims":[{"ClaimTypeReferenceId":"givenname","TransformationClaimType":"sourceClaim"}],
"InputParameters":[{"ID":"regex","Value":".."},{"ID":"replacement","Value":""}],"OutputClaims":[{"ClaimTypeReferenceId":"RemoveInitial","TransformationClaimType":"outputClaim"}]},
{"ID":"RemoveTheZeros","TransformationMethod":"RegexReplace","InputClaims":[{"ClaimTypeReferenceId":"onpremisessamaccountname","TransformationClaimType":"sourceClaim"}],
"InputParameters":[{"ID":"regex","Value":"^0"},{"ID":"replacement","Value":""}],"OutputClaims":[{"ClaimTypeReferenceId":"RemoveZeros","TransformationClaimType":"outputClaim"}]}]
}
}
') -DisplayName "Hearsay-Sandbox-SAML-Policy" -Type "ClaimsMappingPolicy"
New-AzureADPolicy : Error occurred while executing NewPolicy
Code: Request_BadRequest
Message: Property definition has an invalid value.
InnerError:
RequestId: 135eb08f-2ec3-485a-9659-e51a5014607c
DateTimeStamp: Tue, 22 Feb 2022 03:20:04 GMT
HttpStatusCode: BadRequest
HttpStatusDescription: Bad Request
HttpResponseStatus: Completed
At line:1 char:1
Update:
I tried creating the policy with just the middle name transformation and it didn't take it. I did not like my Regex value of "..*" Not sure why. I am trying to find another transformation method that works.
@Ron Manthe , My apologies for the delay in answering.
Thanks for sharing your finding here which will benefit others in the community who are dealing with a similar problem. In addition, I would to like to share my findings here and hope this would also helpful.
**RegEx to Remove Middle Initial in a Given Name field : **
Example:1 Name for Example is John J Smith and Final outcome would be JohnSmith note: there is no spaces.
"InputParameters": [ { "ID": "regex", "Value": " . " }, { "ID": "replacement", "Value": "" } ]
Example:2 Name for Example is John J Smith and Final outcome would be John Smith note: there is a space between first and last name.
"InputParameters": [ { "ID": "regex", "Value": " . " }, { "ID": "replacement", "Value": " " } ]
RegEx to remove all the leading zeros :
"InputParameters": [ { "ID": "regex", "Value": "^0" }, { "ID": "replacement", "Value": "" } ]
-----
Please "Accept the answer" if the information helped you. This will help us and others in the community as well.