Getting from a SPID to an AX user id and back

Earlier versions of AX offered information about the SPID from within AX and the Online Users form. In AX 2012 it is a bit more tricky and requires a little tweaking of the AOS configuration.

What you need to do is to add a key in the registration database and it goes like this:

1. Run regedit.exe

2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dynamics Server\6.0\<ServerNumber>\<MyConfigurationName>. If you have not changed the configuration of the AOS it is named “Original (installed configuration)”.

2. Add a key of the type String Value, name it connectioncontext and give it the value of 1

3. Restart your AOS

If you have multiple AOS-instances you need to repeat the above for each AOS server.

Now we can use this statement to get a list of active queries:

SELECT cast(context_info AS VARCHAR(128)) AS [Connection info] , *
FROM sys.dm_exec_sessions
WHERE program_name LIKE '%Dynamics%'
	AND host_name LIKE '<AOSNameMask>'

If your AOS servers are named MyAOS01, MyAOS02, MyAOS03 and so forth put in MyAOS% as the <AOSNameMask>.

Now, the result is in the first column a variety of information including the AX user id and the AX session id. This can be matched directly to the online users overview within AX.

You can go the other way around by adding this

AND context_info like ' <AXUserId>%'

where <AXUserId> is the relevant id of the user in AX. Notice the initial blank in the range value.


2 thoughts on “Getting from a SPID to an AX user id and back

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s