question

ManteraS-4931 avatar image
0 Votes"
ManteraS-4931 asked ManteraS-4931 commented

Claims, custom Regex search replace certain values

Hi,

I have a incoming claim in my Claims provider trust flow.

Rule language in ADFS:

c:[Type == "serialNumber"]
=> issue(Type = "http://mydomain.tld/claims/2017/06/serialnumber", Issuer = c.Issuer, OriginalIssuer = c.OriginalIssuer, Value = c.Value, ValueType = c.ValueType);

So, the question and problem I would like to solve:

I want to send all the claim values as normal, but if it finds the serial number as below, i want them to be replaced as below

If incoming value are 09843877771 it should be replaced with outgoing value of 434365122
If incoming value are 098432224 it should be replaced with outgoing value of 3827699
If incoming value are 1218719 it should be replaced with outgoing value of 370981128817632



adfs
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

piaudonn avatar image
0 Votes"
piaudonn answered ManteraS-4931 commented

Many ways to do it. This is one. Assuming you extract the serialNumber from AD.

Create a custom rule to extract and only add the serialNumber to the claim pipeline:

 c:[Type == "http://schemas.microsoft.com/ws/2008/06/identity/claims/windowsaccountname", Issuer == "AD AUTHORITY"]
  => add(store = "Active Directory", types = ("http://mydomain.tld/claims/2017/06/serialnumber"), query = ";serialNumber;{0}", param = c.Value);

Then do a nested replace of the value in a second custom rule:

 c:[Type == "http://mydomain.tld/claims/2017/06/serialnumber"]
  => issue(Type = "http://mydomain.tld/claims/2017/06/serialnumber", Value = RegExReplace(RegExReplace(RegExReplace(c.Value, "^1218719$", "370981128817632"), "^098432224$", "3827699"), "^09843877771$", "434365122"));

You need to have them in this order.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thank you so much!!

0 Votes 0 ·