Как получить текущую дату и время в пользовательской политике объявления b2 c в виде заявки - PullRequest
0 голосов
/ 22 января 2020

Я пытаюсь получить текущую дату и время в виде заявки в пользовательских политиках, я пытаюсь использовать одно из преобразований заявки, упомянутых здесь

Для этого создайте два типы заявок:

            <ClaimType Id="currentDateTime">
                <DisplayName>currentDateTime</DisplayName>
                <DataType>dateTime</DataType>
            </ClaimType>

            <ClaimType Id="systemDateTime">
                <DisplayName>currentDateTime</DisplayName>
                <DataType>dateTime</DataType>
            </ClaimType>

Добавлено преобразование заявки:

<ClaimsTransformation Id="GetSystemDateTime" TransformationMethod="GetCurrentDateTime">
  <OutputClaims>
    <OutputClaim ClaimTypeReferenceId="systemDateTime" TransformationClaimType="currentDateTime" />
  </OutputClaims>
</ClaimsTransformation>

В одном из технических профилей указано преобразование заявки:

        <TechnicalProfile Id="LocalAccountSignUpWithLogonCustomUserNameProfile">
                    <DisplayName>UserName signup</DisplayName>
                    <Protocol Name="Proprietary" Handler="Web.TPEngine.Providers.SelfAssertedAttributeProvider, Web.TPEngine, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
                    <Metadata>
                        <Item Key="IpAddressClaimReferenceId">IpAddress</Item>
                        <Item Key="ContentDefinitionReferenceId">api.localaccountsignup.name</Item>
                        <Item Key="language.button_continue">NEXT</Item>
                        <Item Key="setting.showCancelButton">false</Item>
                    </Metadata>
                    <CryptographicKeys>
                        <Key Id="issuer_secret" StorageReferenceId="B2C_1A_TokenSigningKeyContainer" />
                    </CryptographicKeys>
                    <PersistedClaims>
                        <PersistedClaim ClaimTypeReferenceId="email" />
                        <PersistedClaim ClaimTypeReferenceId="phone"  />
                        <PersistedClaim ClaimTypeReferenceId="countryCode"  />
                        <PersistedClaim ClaimTypeReferenceId="isEmailPresent" />
                    </PersistedClaims>
                    <OutputClaims>                                              
                        <OutputClaim ClaimTypeReferenceId="givenName" Required="true" />                      
                        <OutputClaim ClaimTypeReferenceId="surName" Required="true" />
                    </OutputClaims>
                    <OutputClaimsTransformations>
                        <OutputClaimsTransformation ReferenceId="GetSystemDateTime" />
                    </OutputClaimsTransformations>
                 </TechnicalProfile>

И пытается записать данные в B2 C, используя следующий TP:

  <TechnicalProfile Id="AAD-UserWriteUsingLogonUserNameAsEmail">
                    <Metadata>
                        <Item Key="Operation">Write</Item>
                        <Item Key="RaiseErrorIfClaimsPrincipalAlreadyExists">true</Item>
                    </Metadata>
                    <IncludeInSso>false</IncludeInSso>
                    <InputClaims>
                        <InputClaim ClaimTypeReferenceId="email" PartnerClaimType="signInNames.emailAddress" />
                    </InputClaims>
                    <PersistedClaims>
                        <!-- Required claims -->
                        <PersistedClaim ClaimTypeReferenceId="email" PartnerClaimType="signInNames.emailAddress" />
                        <PersistedClaim ClaimTypeReferenceId="newPassword" PartnerClaimType="password"/>
                        <PersistedClaim ClaimTypeReferenceId="displayName" DefaultValue="unknown" />
                        <PersistedClaim ClaimTypeReferenceId="passwordPolicies" DefaultValue="DisablePasswordExpiration, DisableStrongPassword" />

                        <!-- Optional claims. -->
                        <PersistedClaim ClaimTypeReferenceId="givenName" />
                        <PersistedClaim ClaimTypeReferenceId="surname" />
                        <PersistedClaim ClaimTypeReferenceId="currentDateTime" PartnerClaimType="extension_tncaccepteddatetime" />
                    </PersistedClaims>
                    <OutputClaims>
                        <OutputClaim ClaimTypeReferenceId="objectId" />
                        <OutputClaim ClaimTypeReferenceId="newUser" PartnerClaimType="newClaimsPrincipalCreated" />
                        <OutputClaim ClaimTypeReferenceId="authenticationSource" DefaultValue="localAccountAuthentication" />
                        <OutputClaim ClaimTypeReferenceId="userPrincipalName" />
                        <OutputClaim ClaimTypeReferenceId="signInNames.emailAddress" />
                        <OutputClaim ClaimTypeReferenceId="signInNames.phoneNumber" />
                    </OutputClaims>
                    <IncludeTechnicalProfile ReferenceId="AAD-Common" />
                    <UseTechnicalProfileForSessionManagement ReferenceId="SM-AAD" />
                </TechnicalProfile>

Но, читая пользователя, я не получаю форму значения B2 C.

1 Ответ

0 голосов
/ 23 января 2020

Проблема исправлена, мало что сделал. Прежде всего, не требуется ClaimType currentDateTime и добавленное преобразование заявки:

<ClaimsTransformation Id="GetNewUserAgreeToTermsOfUseConsentDateTime" TransformationMethod="GetCurrentDateTime">
                <OutputClaims>
                    <OutputClaim ClaimTypeReferenceId="extension_tncaccepteddatetime" TransformationClaimType="currentDateTime" />
                </OutputClaims>
</ClaimsTransformation>

здесь extension_tncaccepteddatetime - это мой тип заявки типа dateTime:

<ClaimType Id="extension_tncaccepteddatetime">
      <DisplayName>extension_tncaccepteddatetime</DisplayName>
      <DataType>dateTime</DataType>
</ClaimType>

Добавлен как сильный текст в качестве входного утверждения для TP и добавлен InputClaimTransformation в TP:

<InputClaims>
   <InputClaim ClaimTypeReferenceId="extension_tncaccepteddatetime" />
</InputClaims>
<InputClaimsTransformations>
   <InputClaimsTransformation ReferenceId="GetNewUserAgreeToTermsOfUseConsentDateTime" />
</InputClaimsTransformations>

И добавлен в качестве постоянного утверждения:

<PersistedClaim ClaimTypeReferenceId="extension_tncaccepteddatetime" />

Готово!

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...