Claims, custom Regex search replace certain values

ManteraS 21 Reputation points
2021-09-07T22:11:47.013+00:00

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

Active Directory Federation Services
Active Directory Federation Services
An Active Directory technology that provides single-sign-on functionality by securely sharing digital identity and entitlement rights across security and enterprise boundaries.
1,214 questions
0 comments No comments
{count} votes

Accepted answer
  1. Pierre Audonnet - MSFT 10,166 Reputation points Microsoft Employee
    2021-09-09T13:48:39.75+00:00

    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.


0 additional answers

Sort by: Most helpful