Finding User Sessions from SPID in Dynamics AX 2012

In previous versions of Dynamics AX, the “Online Users” form contained a column for SPID for each client sessions. This column was a useful tool in debugging blocked SPID. More specifically, it was used to find a user session that corresponded to a specific SPID as indicated in this blog post. In Microsoft Dynamics AX 2012 the SPID column is no longer available on the “Online Users” form. This post will describe how to find the user session corresponding to a particular SPID.

In Dynamics AX 2012, information about the user sessions can be directly included in the SQL connection context. Adding  this information has a small performance overhead. Therefore, it is not turned on by default. To include user session information in the connection context perform the following steps:

  1. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dynamics Server\6.0\01\Original (installed configuration). The last key, Original (installed configuration), is the key name for the current server configuration. If your system uses a different configuration that the original installed configuration, navigate to the currently active configuration.
  2. Create a string registry value called ‘connectioncontext’ and set the value to 1.
  3. Restart the AOS.

Next open SQL Server Management Studio and run the following query to look at all the sessions related to Microsoft Dynamics AX:

select cast(context_info as varchar(128)) as ci,* from sys.dm_exec_sessions where program_name like '%Dynamics%'

Here’s the sample output. Let’s take a closer look at the ci column.


The first two items in the connection information are AX user id and the AX session id. So for SQL session_id 60 the user is ‘Admin’ and AX session id is 3. Next we can open the “Online Users” form to find the user session associated with the SPID.


Comments (10)

  1. Anonymous says:

    what does the rest of the information in the context info do? what does 'read only 5' mean?

  2. The rest of the parameters are for internal debugging only. Thanks.

  3. Anonymous says:

    how do you see in the sql output on which aos the ax user connection info is from

  4. Anonymous says:

    Really nice,  thank you for this tip

  5. Anonymous says:

    The system seems to be updating context information for not only 'native' AOS connections, but ODBC connections open from X++ code as well, which is convenient. The only problem is that T-SQL statement it uses will fail in case these are not Microsoft SQL Server DSN (in my scenario it is Oracle DB)

  6. Anonymous says:

    Hi I did the same thing which is described here. When i execute query i am not getting the first column. Its showing me as empty. Can you please help me ? Thanks in advance.

  7. Anonymous says:

    I am having the same issue as Raas.  Made the registry change and restarted the service but the context column is still blank.  Any help/suggestions would be appreciated.

  8. Anonymous says:

    I am having the same issue as Raas and John. Made registry changes on AOS server. When running the SQL command on DB server the ci column is blank

  9. You need to create the new key on the Active configuration. In doubt, I recommend to create the key on all AOS configurations.

  10. Phil says:

    I had the same issue but then realized there was  DEBUG config that was actually being used instead of the original config.  That worked for me.  

Skip to main content