Pages

29 June, 2021

Sitecore Marketing Automation Engine fails to start - Possibly Certificate Access Issue

If the Sitecore Marketing Automation Engine service fails to start after the installation, then most of them time, it must be due to certificate access issue. 

If your application pool is using a dedicated service account, then take a note of the service account name. 

If the application pool is configured with ApplicationPoolIdentity, then you can get the IIS Website name for each role. For example, if the IIS Website name is sc101.local.cm, then ApplicationPoolIdentity will be "IIS AppPool\sc101.local.cm". 

Once you have got the name of the account, then

  • Select Run from the Start menu, and then enter certlm.msc
  • Under Certificates - Local Computer in the left pane, expand the directory Personal - Certificates.
  • Choose xConnect Certificate, Right Click - All Tasks - Manage Private Keys.
  • In the Permission window, click Add and paste the account name and Apply.


     

25 June, 2021

Sitecore Upgrade - Transferred Sitecore Membership User Password does not work - Possible Reasons

In case if you have migrated the password using Sitecore utility as mentioned here, your migrated password may not work. Some of the steps which are mentioned below may help. 

  1. Check whether the script ran successfully on the current server
    You may need to confirm whether the source and destination server used to migrate the password is correct and also whether the destination server has all the users and password. 

  2. Check the Membership Password hashAlgorithmType
    You may need to check whether the hashAlgorithmType is same in the source and the destination Sitecore instance. You can view it in the web.config file in <membership> node. Attribute name is hashAlgorithmType. For the migrated password to work, destination hashAlgorithmType should be same as source hashAlgorithmType. 

  3. Migration to Sitecore 9.2 with Identity Provider
    In case if the destination server is going to use Siteore Identity Provider to authenticate the Sitecore membership users, then you will need to set the same hashAlgorithmType in Identity server configuration. 

    In the Sitecore ID server, go to \sitecore\Sitecore.Plugin.IdentityServer\Config\identityServer.xml file and set the same hashAlgorithmType which is used in source server in <PasswordHashAlgorithm> tag. Do not forget to recycle the Identity server application pool after this change. 


Sitecore Upgrade - Transfer Sitecore Membership User/Roles and Password

As part of the Sitecore upgrade, if you have a requirement to transfer Sitecore Membership roles, users and their password, then you can follow this process. 

In case if you have upgraded the core database from one Sitecore version to another, you may not be able to use the same password unless you reset it. 

Transfer Users and Roles using Sitecore Package
To transfer the users and roles, you can use Sitecore Package or by serializing user accounts on one instance and de-serializing them on another instance or easiest way is it to use Sitecore PowerShell Extension. Below piece of script will get all the users and roles from the current version and provide a package.

Once the package is ready, you can use Sitecore Package Installer to install and click Continue Always if there is an user or role already available in the destination server, you can click Continue Always to proceed. 

Transfer Password to new environment
Bringing the users and roles to the new environment will not bring the password. It may be necessary to manually reset user passwords after the transfer. Sitecore provided a simple utility to transfer the passwords to the destination server. 


You have to place the admin web page, provide the source and destination core or security db connection string. You will get an option to select the users to migrate their passwords. In the Sitecore provided file, you have to select one user at a time to move from left to right. 

I modified to add a button to transfer all the available user's passwords in a single click of a button (Transfer All). You can get the updated file here

Note: In order for the tool to list the users, you need to make sure the users are already transferred to the destination Sitecore instance. 



11 June, 2021

Sitecore - Post condition failed exception

After upgrading from Sitecore 9.0.1 to Sitecore 10.0.1, there was an error reported in CD environment. "Post condition failed"

This is due to the reference of Core Database in CD server. From Sitecore 9.2, Sitecore has removed the reference of core database in Content Delivery and introduced Security database connection string which can store the aspnet membership tables. 

In my case, I had a reference of Core database in a custom configuration which modified the prefetch cacheSize. Once I removed it, site loaded fine. 
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <databases>
      <database id="core">
        <dataProviders hint="list:AddDataProvider">
          <dataProvider param1="$(id)">
            <prefetch>
              <cacheSize>200MB</cacheSize>
            </prefetch>
          </dataProvider>
        </dataProviders>
      </database>      
  </sitecore>
</configuration>

Exception:
Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 6/11/2021 10:32:01 AM 
Event time (UTC): 6/11/2021 3:32:01 PM 
Event ID: 8bb3c123c9f64b1dbf6201fddf35994b 
Event sequence: 2 
Event occurrence: 1 
Event detail code: 0 
 
Application information: 
    Application domain: /LM/W3SVC/2/ROOT-3-132678991184217924 
    Trust level: Full 
    Application Virtual Path: / 
    Application Path: C:\inetpub\wwwroot\cd\ 
    Machine name: CD 
 
Process information: 
    Process ID: 11156 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\cd 
 
Exception information: 
    Exception type: InvalidOperationException 
    Exception message: Post condition failed
   at Sitecore.Diagnostics.Assert.ResultNotNull[T](T result, String message)
   at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
   at Sitecore.Configuration.DefaultFactory.GetDatabases()
   at Sitecore.Data.Managers.DefaultItemManager.Initialize()
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Nexus.Web.HttpModule.Application_Start()
   at Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app)
   at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
   at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

 
 
Request information: 
    Request URL: https://cd:443/
    Request path: /
    User host address: 192.168.1.137 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\cd 
 
Thread information: 
    Thread ID: 31 
    Thread account name: IIS APPPOOL\cd 
    Is impersonating: False 
    Stack trace:    at Sitecore.Diagnostics.Assert.ResultNotNull[T](T result, String message)
   at Sitecore.Configuration.DefaultFactory.GetDatabase(String name)
   at Sitecore.Configuration.DefaultFactory.GetDatabases()
   at Sitecore.Data.Managers.DefaultItemManager.Initialize()
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at (Object , Object )
   at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
   at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
   at Sitecore.Nexus.Web.HttpModule.Application_Start()
   at Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app)
   at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
   at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
   at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
   at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)
 

04 June, 2021

Sitecore RenderingContext.Current.Rendering.Item changed? - Sitecore 9 vs Sitecore 10

As part of  Sitecore 9 to Sitecore 10 upgrade, few components did not work after the upgrade and it was related to the rendering datasource.

Problem: I have a datasource on an ancestor Controller rendering. Child Controller rendering does not have a datasource. Child Controller rendering uses ancestor rendering datasource Item to render the data. After the Sitecore 10 upgrade, Child Controller rendering couldn't get the ancestor datasource item using RenderingContext.Current.Rendering.Item and instead it returned page content Item. 

There is a great blog on Sitecore MVC Rendering datasource topic by Matthew Dresser. He explains about RenderingContext.Current.Rendering.Item clearly. It helps to "get datasource of the current rendering, or the datasource of an ancestor rendering if specified, or the page item if no datasource set and no ancestor rendering with datasource. Rendering datasource takes priority". Datasource of an ancestor rendering will be returned if the setting Mvc.AllowDataSourceNesting is true. It is true by default.

After the upgrade, RenderingContext.Current.Rendering.Item does not return ancestor rendering datasource and instead it returns Page context item. 

Raised a Sitecore Support ticket whether it is an expected change or a bug. Will update once I hear from them.

As workaround, I wanted it to behave in the same fashion to reduce the impact. I added a wrapper method which gives priority to child rendering datasource if available, then ancestor rendering datasource if available and then page context item. 

References:

01 June, 2021

ReferenceError: URL is not defined

If you are using Node 8.11.2-x64, you may experience the below error when trying to fetch client packages like bootstrap or jquery from the source. 

1579 verbose stack ReferenceError: URL is not defined
1579 verbose stack     at regKeyFromURI (C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\auth.js:7:18)
1579 verbose stack     at getAuth (C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\auth.js:49:18)
1579 verbose stack     at regFetch (C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\npm-registry-fetch\index.js:55:16)
1579 verbose stack     at RemoteFetcher.[pacote.Fetcher._tarballFromResolved] (C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\remote.js:40:5)
1579 verbose stack     at tryAgain (C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\pacote\lib\fetcher.js:303:64)
1579 verbose stack     at C:\Users\Nehem\AppData\Roaming\npm\node_modules\npm\node_modules\promise-retry\index.js:29:24
1579 verbose stack     at <anonymous>

Permanent Fix: Upgrade the node to v9.8.0 which will resolve the issue. 

Workaround: In case if you can't or don't want to upgrade, you can add the var URL = require('url').URL; in the js file mentioned in the stacktrace (here: \node_modules\npm-registry-fetch\auth.js) and it should resolve the issue. Stackoverflow reference