Hi All,
Is there a way to remove instantly all the active users on Dynamics AX 2009? I mean, all open/online AX application will be close automatically once I run a specific script?
Currently I have a job that will kill all the online users using SQL job. During my testing on DEV environment I open five (5) AX application on different computers then I run the SQL job to kill connection. When I check the online user all of them are remove on the Administration-->Online Users-->Client Session> but whether they already remove on the online users, the AX application of the five users or the front end AX is still working or did not close automatically.
Here is one of the step in my script to kill online users;
---
UPDATE [SysClientSessions]
SET [Status] = 0
----
Please help.
Thanks...
*This post is locked for comments
"Killing" sessions is a horrible idea, especially from SQL Server - you are breaking business logic that will quickly cause your AX database to be corrupted.
If you want to block users, the correct way is to drain the AX AOS from the online users form once you have started your client after restarting a single AX AOS account.
Since for newer versions of AX draining can cause issues on some maintenance steps, I have changed the code where I set a custom Maintenance checkbox within the AX Server configuration form in the System administration module, and when the flag is set, I end non-sysadmin sessions in \Classes\Application\startupPost() method by calling something like this. Code should be compatible with AX 2009 with minor changes. You could use a timeout in case you want to show up a dialog box or something for the user informing about the maintenance mode.
public static void WIK_validateMaintenanceMode() { xSession axSession = new xSession(); ServerId currentAOSInstance = Session::getAOSInstance() + '@' + axSession.AOSName(); if (isRunningMode() && !SysModelStore::isInstallMode() && (!isDeveloper() || !isSystemAdministrator()) && (select firstOnly WIK_Maintenance from SysServerConfig where SysServerConfig.ServerId == currentAOSInstance).WIK_Maintenance == NoYes::Yes) { infolog.addTimeOut(appl, methodStr(Application, WIK_shutdown), 100, false); } }
public void WIK_shutdown()
{
infolog.shutDown(true);
}
If you want to be sure that nobody is using AX while you're maintaining the database, simply stop AOS services.
Nevertheless rebuilding indexes can normally be done with users using the system.
Hi Jean,
There are few other option, You may want to check out,
Limiting user sessions(Set Timeout For User Session) (theaxapta.blogspot.in/.../limiting-user-sessionsset-timeout-for.html)
Restrict Multiple Time login of a same user (theaxapta.blogspot.in/.../how-to-restrict-multiple-time-login-of.html)
Hi Martin,
Thanks for your advice, i appreciate that much. But I was using the script for our maintenance plan and i want to make sure that no one is using the dynamics ax once I run my reindex script.
Doesn't AX 2009 have a button on the Online users form to terminate user sessions? If so, you can use the same logic.
Never meddle with data directly in database; you're forgetting that there running processes that already has the data loaded and you could introduce various data corruption. Work through the application.
You already complained on another forum that your script causes AOS to crash, so it should be obvious to you that it's not a good approach.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,151 Super User 2024 Season 2
Martin Dráb 229,963 Most Valuable Professional
nmaenpaa 101,156