Restrict user login for multiple times in ax2009 through X++


Copy Paste the Following Code in startupPost method of info class in AOT.

void startupPost()
{
// To restrict user login form second login
xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;
;
currentUserId = curUserId();
if(currentUserId!=”Admin”)// Allow Admin User to login multiple time
{
while select SysClientSessions
where SysClientSessions.userId == currentUserId &&
SysClientSessions.Status == 1 // 1 : Login 0 : Logout
{
session = new xSession(SysClientSessions.SessionId, true);
if (session && session.userId())
{
counter++;
}
}
if(counter>=2)
{
Box::stop(“Already Logged-in : The same user id can’t log in twice.”);
infolog.shutDown(true);
}
}
}
Please take backup of your application before copying code.


Happy Daxing J

1 comment:

The Moment Tokens, Vectors, and Models Click, AI Starts Making Sense

  You've probably heard these terms dozens of times by now. They're showing up in AI discussions, Copilot demos, Azure OpenAI conver...

Powered by Blogger.