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 boolean 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
## AndClaims
@@ -30,6 +28,9 @@ Performs an And operation of two boolean inputClaims and sets the outputClaim wi
30
28
| InputClaim | inputClaim2 | boolean | The second ClaimType to evaluate. |
31
29
|OutputClaim | outputClaim | boolean | The ClaimTypes that will be produced after this claims transformation has been invoked (true or false). |
32
30
31
+
32
+
### Example of AndClaims
33
+
33
34
The following claims transformation demonstrates how to And two boolean ClaimTypes: `isEmailNotExist`, and `isSocialAccount`. The output claim `presentEmailSelfAsserted` is set to `true` if the value of both input claims are `true`. In an orchestration step, you can use a precondition to preset a self-asserted page, only if a social account email is empty.
34
35
35
36
```xml
@@ -44,13 +45,11 @@ The following claims transformation demonstrates how to And two boolean ClaimTyp
44
45
</ClaimsTransformation>
45
46
```
46
47
47
-
### Example of AndClaims
48
-
49
48
- Input claims:
50
-
-**inputClaim1**: true
51
-
-**inputClaim2**: false
49
+
-**inputClaim1**: true
50
+
-**inputClaim2**: false
52
51
- Output claims:
53
-
-**outputClaim**: false
52
+
-**outputClaim**: false
54
53
55
54
56
55
## AssertBooleanClaimIsEqualToValue
@@ -66,6 +65,8 @@ The **AssertBooleanClaimIsEqualToValue** claims transformation is always execute
The following claims transformation demonstrates how to check the value of a boolean ClaimType with a `true` value. If the value of the `accountEnabled` ClaimType is false, an error message is thrown.
70
71
71
72
```xml
@@ -79,38 +80,46 @@ The following claims transformation demonstrates how to check the value of a boo
79
80
</ClaimsTransformation>
80
81
```
81
82
83
+
- Input claims:
84
+
-**inputClaim**: false
85
+
-**valueToCompareTo**: true
86
+
- Result: Error thrown
87
+
88
+
### Calling the AssertBooleanClaimIsEqualToValue claims transformation
82
89
83
-
The `login-NonInteractive` validation technical profile calls the `AssertAccountEnabledIsTrue` claims transformation.
90
+
The following `Example-AssertBoolean` validation technical profile calls the `AssertAccountEnabledIsTrue` claims transformation.
Checks that boolean value of a claim is equal to `true` or `false`, and return the result of the compression.
@@ -121,6 +130,8 @@ Checks that boolean value of a claim is equal to `true` or `false`, and return t
121
130
| InputParameter |valueToCompareTo | boolean | The value to compare (true or false). |
122
131
| OutputClaim | compareResult | boolean | The ClaimType that is produced after this ClaimsTransformation has been invoked. |
123
132
133
+
### Example of CompareBooleanClaimToValue
134
+
124
135
The following claims transformation demonstrates how to check the value of a boolean ClaimType with a `true` value. If the value of the `IsAgeOver21Years` ClaimType is equal to `true`, the claims transformation returns `true`, otherwise `false`.
125
136
126
137
```xml
@@ -137,14 +148,12 @@ The following claims transformation demonstrates how to check the value of a boo
137
148
</ClaimsTransformation>
138
149
```
139
150
140
-
### Example of CompareBooleanClaimToValue
141
-
142
151
- Input claims:
143
-
-**inputClaim**: false
152
+
-**inputClaim**: false
144
153
- Input parameters:
145
-
-**valueToCompareTo**: true
154
+
-**valueToCompareTo**: true
146
155
- Output claims:
147
-
-**compareResult**: false
156
+
-**compareResult**: false
148
157
149
158
## NotClaims
150
159
@@ -155,7 +164,9 @@ Performs a Not operation of the boolean inputClaim and sets the outputClaim with
155
164
| InputClaim | inputClaim | boolean | The claim to be operated. |
156
165
| OutputClaim | outputClaim | boolean | The ClaimTypes that are produced after this ClaimsTransformation has been invoked (true or false). |
157
166
158
-
Use this claim transformation to perform logical negation on a claim.
167
+
### Example of NotClaims
168
+
169
+
The following claim transformation demonstrates how to perform logical negation on a claim.
@@ -168,12 +179,10 @@ Use this claim transformation to perform logical negation on a claim.
168
179
</ClaimsTransformation>
169
180
```
170
181
171
-
### Example of NotClaims
172
-
173
182
- Input claims:
174
-
-**inputClaim**: false
183
+
-**inputClaim**: false
175
184
- Output claims:
176
-
-**outputClaim**: true
185
+
-**outputClaim**: true
177
186
178
187
## OrClaims
179
188
@@ -185,6 +194,8 @@ Computes an Or of two boolean inputClaims and sets the outputClaim with result o
185
194
| InputClaim | inputClaim2 | boolean | The second ClaimType to evaluate. |
186
195
| OutputClaim | outputClaim | boolean | The ClaimTypes that will be produced after this ClaimsTransformation has been invoked (true or false). |
187
196
197
+
### Example of OrClaims
198
+
188
199
The following claims transformation demonstrates how to `Or` two boolean ClaimTypes. In the orchestration step, you can use a precondition to preset a self-asserted page, if the value of one of the claims is `true`.
189
200
190
201
```xml
@@ -199,10 +210,12 @@ The following claims transformation demonstrates how to `Or` two boolean ClaimTy
199
210
</ClaimsTransformation>
200
211
```
201
212
202
-
### Example of OrClaims
203
-
204
213
- Input claims:
205
-
-**inputClaim1**: true
206
-
-**inputClaim2**: false
214
+
-**inputClaim1**: true
215
+
-**inputClaim2**: false
207
216
- Output claims:
208
-
-**outputClaim**: true
217
+
-**outputClaim**: true
218
+
219
+
## Next steps
220
+
221
+
- 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
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
@@ -57,12 +57,12 @@ The following example compares the `currentDateTime` claim with the `approvedDat
| 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
113
-
114
-
The following example demonstrates the conversion of the claim `dateOfBirth` (date data type) to another claim `dateOfBirthWithTime` (dateTime data type).
| InputClaim | inputClaim | date | The claim type to be converted. |
139
+
| OutputClaim | outputClaim | dateTime | The claim type that is produced after this claims transformation has been invoked. |
140
+
141
+
### Example of ConvertDateToDateTimeClaim
142
+
143
+
The following example demonstrates the conversion of the claim `dateOfBirth` (date data type) to another claim `dateOfBirthWithTime` (dateTime data type).
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`.
@@ -173,7 +173,7 @@ Compares two dates and determines whether the first date is later, earlier, or e
173
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
174
To run the claim transformation, you first need to get the current date and also the last time user accepts the TOS.
175
175
176
-
### DateTimeComparison example
176
+
### Example of DateTimeComparison
177
177
178
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).
179
179
@@ -194,13 +194,13 @@ The following example shows that the first date (2022-01-01T00:00:00) plus 90 da
194
194
```
195
195
196
196
- Input claims:
197
-
-**firstDateTime**: 2022-01-01T00:00:00.100000Z
198
-
-**secondDateTime**: 2022-03-16T00:00:00.100000Z
197
+
-**firstDateTime**: 2022-01-01T00:00:00.100000Z
198
+
-**secondDateTime**: 2022-03-16T00:00:00.100000Z
199
199
- Input parameters:
200
-
-**operator**: later than
201
-
-**timeSpanInSeconds**: 7776000 (90 days)
200
+
-**operator**: later than
201
+
-**timeSpanInSeconds**: 7776000 (90 days)
202
202
- Output claims:
203
-
-**result**: true
203
+
-**result**: true
204
204
205
205
## GetCurrentDateTime
206
206
@@ -210,7 +210,7 @@ Get the current UTC date and time and add the value to a claim type.
0 commit comments