Recently we have faced an error during SSRS report printouts, where the quick fix was to temporarily disable CIL execution for all regular AX user accounts.

The error message was as per below, and this MSDN blog post has pointed us in the right direction of resolving the problem:

Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics.

The following job can be used to disable CLR operations. It essentially changes the Execute business operations in CIL setting under Options > Development tab based on the flag defined:

static void WIK_setCILexecution(Args _args)
{
    #LOCALMACRO.FLAG_ExecBusinessOpsWithInterpreter (1 << 10) #ENDMACRO
    
    UserInfo            userInfo;
    boolean             setEnabled = false;
    
    ttsBegin;
    
    while select forUpdate DebugInfo from userInfo
        where userInfo.accountType  == UserAccountType::ADUser
            && userInfo.enable      == NoYes::Yes
    {
        if (setEnabled)
        {
            userInfo.DebugInfo  = userInfo.DebugInfo ^ #FLAG_ExecBusinessOpsWithInterpreter;
        }
        else
        {
            userInfo.DebugInfo  = userInfo.DebugInfo | #FLAG_ExecBusinessOpsWithInterpreter;
        }
        userInfo.update();
    }
    
    ttsCommit;
}

Please note that users need to reopen their AX clients in order for the changes to take effect, since it is driven by a flag stored in their object cache.

Once the problem is resolved it is advised to re-enable CIL execution to improve system performance.