我终于能够使用声明转换来做到这一点。
根据 Microsoft 声明解析器目前不能与持久声明一起使用。他们正在努力为更多技术配置文件类型启用此功能。
以下是执行此操作的详细步骤。
第 1 步:首先添加两个声明
<ClaimType Id="extension_LastLoginDate">
<DisplayName>last time user logged in</DisplayName>
<DataType>dateTime</DataType>
<UserHelpText>last time user logged in</UserHelpText>
</ClaimType>
<ClaimType Id="CurrentTime">
<DisplayName>Current time</DisplayName>
<DataType>dateTime</DataType>
<UserHelpText>Current time</UserHelpText>
</ClaimType>
第一个是扩展属性,用于将值存储在 AD 中。第二个是保存当前日期时间的临时变量。
第 2 步:添加新的声明转换,这是在 CurrentTime 声明中获取当前数据时间 (utc) 所必需的
<ClaimsTransformation Id="GetSystemDateTime" TransformationMethod="GetCurrentDateTime">
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="CurrentTime" TransformationClaimType="currentDateTime" />
</OutputClaims>
</ClaimsTransformation>
第 3 步:定义技术配置文件以更新 extension_LastLoginDate 属性
<TechnicalProfile Id="Custom-TP-AAD-WriteLastLoginDateUsingObjectId">
<Metadata>
<Item Key="Operation">Write</Item>
<Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
</Metadata>
<IncludeInSso>false</IncludeInSso>
<InputClaims>
<InputClaim ClaimTypeReferenceId="objectId" Required="true" />
</InputClaims>
<PersistedClaims>
<PersistedClaim ClaimTypeReferenceId="objectId" />
<PersistedClaim ClaimTypeReferenceId="CurrentTime" PartnerClaimType="extension_LastLoginDate" />
</PersistedClaims>
<IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>
第 4 步:更新现有技术资料 AAD-UserReadUsingObjectId。这是一个重要的步骤,您将调用索赔转换并将CurrentTime 索赔添加到索赔包中。我使用了AAD-UserReadUsingObjectId 技术配置文件,但它可以是任何其他技术配置文件,只要确保已调用索赔转换并将CurrentTime 索赔添加到索赔包。
<TechnicalProfile Id="AAD-UserReadUsingObjectId">
<Metadata>
<Item Key="Operation">Read</Item>
<Item Key="RaiseErrorIfClaimsPrincipalDoesNotExist">true</Item>
</Metadata>
<IncludeInSso>false</IncludeInSso>
<InputClaims>
<InputClaim ClaimTypeReferenceId="objectId" Required="true" />
</InputClaims>
<OutputClaims>
<OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" />
<OutputClaim ClaimTypeReferenceId="displayName" />
<OutputClaim ClaimTypeReferenceId="objectId" />
<OutputClaim ClaimTypeReferenceId="CurrentTime" />
</OutputClaims>
<OutputClaimsTransformations>
<OutputClaimsTransformation ReferenceId="GetSystemDateTime" />
</OutputClaimsTransformations>
<IncludeTechnicalProfile ReferenceId="AAD-Common" />
</TechnicalProfile>
第 5 步:最后,您可以在任何用户旅程中从 OrchestrationStep 之一调用 Custom-TP-AAD-WriteLastLoginDateUsingObjectIdtechnical 配置文件
<OrchestrationStep Order="5" Type="ClaimsExchange">
<ClaimsExchanges>
<ClaimsExchange Id="WriteLastLogonTime" TechnicalProfileReferenceId="Custom-TP-AAD-WriteLastLoginDateUsingObjectId" />
</ClaimsExchanges>
</OrchestrationStep>