You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This article provides examples for using the date claims transformations of the Identity Experience Framework schema in Azure Active Directory B2C (Azure AD B2C). For more information, see [ClaimsTransformations](claimstransformations.md).
22
20
23
21
## AssertDateTimeIsGreaterThan
24
22
25
-
Checks that one date and time claim (string data type) is later than a second date and time claim (string data type), and throws an exception.
23
+
Asserts that one date is later than a second date. Determines whether the `rightOperand` is greater than the `leftOperand`. If yes, throws an exception.
26
24
27
25
| Item | TransformationClaimType | Data Type | Notes |
| InputClaim | leftOperand | string | First claim's type, which should be later than the second claim. |
30
28
| InputClaim | rightOperand | string | Second claim's type, which should be earlier than the first claim. |
31
-
| InputParameter | AssertIfEqualTo | boolean | Specifies whether this assertion should throw an error if the left operand is equal to the right operand. An error will be thrown if the left operand is equal to the right operand and the value is set to `true`. Possible values: `true` (default), or `false`. |
29
+
| InputParameter | AssertIfEqualTo | boolean | Specifies whether this assertion should throw an error if the left operand is equal to the right operand. Possible values: `true` (default), or `false`. |
32
30
| InputParameter | AssertIfRightOperandIsNotPresent | boolean | Specifies whether this assertion should pass if the right operand is missing. |
33
31
| InputParameter | TreatAsEqualIfWithinMillseconds | int | Specifies the number of milliseconds to allow between the two date times to consider the times equal (for example, to account for clock skew). |
34
32
35
33
The **AssertDateTimeIsGreaterThan** claims transformation is always executed from a [validation technical profile](validation-technical-profile.md) that is called by a [self-asserted technical profile](self-asserted-technical-profile.md). The **DateTimeGreaterThan** self-asserted technical profile metadata controls the error message that the technical profile presents to the user. The error messages can be [localized](localization-string-ids.md#claims-transformations-error-messages).
The following example compares the `currentDateTime` claim with the `approvedDateTime` claim. An error is thrown if `currentDateTime` is later than `approvedDateTime`. The transformation treats values as equal if they are within 5 minutes (30000 milliseconds) difference. It won't throw an error if the values are equal because `AssertIfEqualTo` is set to `false`.
40
40
41
41
```xml
@@ -56,44 +56,60 @@ The following example compares the `currentDateTime` claim with the `approvedDat
56
56
> In the example above, if you remove the `AssertIfEqualTo` input parameter, and the `currentDateTime` is equal to`approvedDateTime`, an error will be thrown. The `AssertIfEqualTo` default value is `true`.
57
57
>
58
58
59
-
The `login-NonInteractive` validation technical profile calls the `AssertApprovedDateTimeLaterThanCurrentDateTime` claims transformation.
| InputClaim | inputClaim | date | The ClaimType to be converted. |
96
-
| OutputClaim | outputClaim | dateTime | The ClaimType that is produced after this ClaimsTransformation has been invoked. |
109
+
| InputClaim | inputClaim | date | The claim type to be converted. |
110
+
| OutputClaim | outputClaim | dateTime | The claim type that is produced after this claims transformation has been invoked. |
111
+
112
+
### ConvertDateToDateTimeClaim example
97
113
98
114
The following example demonstrates the conversion of the claim `dateOfBirth` (date data type) to another claim `dateOfBirthWithTime` (dateTime data type).
99
115
@@ -108,21 +124,21 @@ The following example demonstrates the conversion of the claim `dateOfBirth` (da
108
124
</ClaimsTransformation>
109
125
```
110
126
111
-
### Example
112
-
113
127
- Input claims:
114
-
-**inputClaim**: 2020-15-03
128
+
-**inputClaim**: 2022-01-03
115
129
- Output claims:
116
-
-**outputClaim**: 2020-15-03T00:00:00.0000000Z
130
+
-**outputClaim**: 2022-01-03T00:00:00.0000000Z
117
131
118
132
## ConvertDateTimeToDateClaim
119
133
120
-
Converts a **DateTime** ClaimType to a **Date** ClaimType. The claims transformation removes the time format from the date.
134
+
Converts a `DateTime` claim type to a `Date` claim type. The claims transformation removes the time format from the date.
121
135
122
136
| Item | TransformationClaimType | Data Type | Notes |
Determine whether one dateTime is later, earlier, or equal to another. The result is a new boolean ClaimType boolean with a value of `true` or `false`.
163
+
Compares two dates and determines whether the first date is later, earlier, or equal to another. The result is a new Boolean claim with a value of `true` or `false`.
171
164
172
165
| Item | TransformationClaimType | Data Type | Notes |
| InputClaim | firstDateTime | dateTime | The first dateTime to compare whether it is earlier or later than the second dateTime. Null value throws an exception. |
175
-
| InputClaim | secondDateTime | dateTime | The second dateTime to compare whether it is earlier or later than the first dateTime. Null value is treated as the current datetTime. |
167
+
| InputClaim | firstDateTime | dateTime | The first date to compare whether it's later, earlier, or equal to the second date. Null value throws an exception. |
168
+
| InputClaim | secondDateTime | dateTime | The second date to compare. Null value is treated as the current datetTime. |
169
+
| InputParameter | timeSpanInSeconds | int | Timespan to add to the first date. Possible values: range from negative -2,147,483,648 through positive 2,147,483,647. |
176
170
| InputParameter | operator | string | One of following values: same, later than, or earlier than. |
177
-
| InputParameter | timeSpanInSeconds | int | Add the timespan to the first datetime. |
178
-
| OutputClaim | result | boolean | The ClaimType that is produced after this ClaimsTransformation has been invoked. |
171
+
| OutputClaim | result | boolean | The claim that is produced after this claims transformation has been invoked. |
172
+
173
+
Use this claims transformation to determine if first date plus the timespan parameter is later, earlier, or equal to another. For example, you may store the last time a user accepted your terms of services (TOS). After three months, you can ask the user to access the TOS again.
174
+
To run the claim transformation, you first need to get the current date and also the last time user accepts the TOS.
175
+
176
+
### DateTimeComparison example
179
177
180
-
Use this claims transformation to determine if two ClaimTypes are equal, later, or earlier than each other. For example, you may store the last time a user accepted your terms of services (TOS). After 3 months, you can ask the user to access the TOS again.
181
-
To run the claim transformation, you first need to get the current dateTime and also the last time user accepts the TOS.
178
+
The following example shows that the first date (2022-01-01T00:00:00) plus 90 days is later than the second date (2022-03-16T00:00:00).
- Find more [claims transformation samples](https://github.com/azure-ad-b2c/unit-tests/tree/main/claims-transformation) on the Azure AD B2C community GitHub repo
This article provides examples for using general claims transformations of the Identity Experience Framework schema in Azure Active Directory B2C (Azure AD B2C). For more information, see [ClaimsTransformations](claimstransformations.md).
21
+
This article provides examples for using general claims transformations of the Identity Experience Framework schema in Azure Active Directory B2C (Azure AD B2C). For more information, see [claims transformations](claimstransformations.md).
22
22
23
23
## CopyClaim
24
24
25
25
Copy value of a claim to another. Both claims must be from the same type.
26
26
27
27
| Item | TransformationClaimType | Data Type | Notes |
| InputClaim | inputClaim | string, int | The claim type which is to be copied. |
30
-
| OutputClaim | outputClaim | string, int | The ClaimType that is produced after this ClaimsTransformation has been invoked. |
29
+
| InputClaim | inputClaim | string, int | The claim type, which is to be copied. |
30
+
| OutputClaim | outputClaim | string, int | The claim that is produced after this claims transformation has been invoked. |
31
31
32
32
Use this claims transformation to copy a value from a string or numeric claim, to another claim. The following example copies the externalEmail claim value to email claim.
33
33
@@ -42,7 +42,7 @@ Use this claims transformation to copy a value from a string or numeric claim, t
| InputClaim | inputClaim |Any | The input claim whose existence needs to be verified. |
59
-
| OutputClaim | outputClaim | boolean | The ClaimType that is produced after this ClaimsTransformation has been invoked. |
59
+
| OutputClaim | outputClaim | boolean | The claim that is produced after this claims transformation has been invoked. |
60
60
61
61
Use this claims transformation to check if a claim exists or contains any value. The return value is a boolean that indicates whether the claim exists. Following example checks if the email address exists.
62
62
@@ -71,7 +71,7 @@ Use this claims transformation to check if a claim exists or contains any value.
@@ -87,7 +87,7 @@ Hash the provided plain text using the salt and a secret. The hashing algorithm
87
87
| InputClaim | plaintext | string | The input claim to be encrypted |
88
88
| InputClaim | salt | string | The salt parameter. You can create a random value, using `CreateRandomString` claims transformation. |
89
89
| InputParameter | randomizerSecret | string | Points to an existing Azure AD B2C **policy key**. To create a new policy key: In your Azure AD B2C tenant, under **Manage**, select **Identity Experience Framework**. Select **Policy keys** to view the keys that are available in your tenant. Select **Add**. For **Options**, select **Manual**. Provide a name (the prefix *B2C_1A_* might be added automatically.). In the **Secret** text box, enter any secret you want to use, such as 1234567890. For **Key usage**, select **Signature**. Select **Create**. |
90
-
| OutputClaim | hash | string | The ClaimType that is produced after this claims transformation has been invoked. The claim configured in the `plaintext` inputClaim. |
90
+
| OutputClaim | hash | string | The claim that is produced after this claims transformation has been invoked. The claim configured in the `plaintext` inputClaim. |
- Find more [claims transformation samples](https://github.com/azure-ad-b2c/unit-tests/tree/main/claims-transformation) on the Azure AD B2C community GitHub repo
0 commit comments