How to Restrict Multiple Time login of a same user in ax 2009?
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
SysClientSessions.clientType ==0
{
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);
}
}
}
But its not working for Non Admin group users
Could any one help me
I have tried this one and it doesn’t work for normal users. it required some admin permission.
it looks like that normal users don’t have permission to access SysClientSessions table.
any idea please
Copy paste below code in startupPost method of info class
void startupPost()
{
// To restrict user login form second login
xSession session;
SysClientSessions SysClientSessions;
UserId currentUserId;
int counter;
UserGroupList UserGroupList ;
;
currentUserId = curUserId();
// info(currentUserId);
if(currentUserId != “AdminUser”)
{
while select SysClientSessions
where SysClientSessions.userId == currentUserId && SysClientSessions.Status == 1
{
session = new xSession(SysClientSessions.SessionId, true);
if (session && session.userId())
{
counter++;
}
}
// info(int2str(counter)+ “ct”);
if(counter>=2)
{
Box::stop(“Already Logged-in : The same user id can’t log in twice.”);
infolog.shutDown(true);
// info(“close”);
}
}
}
You can skip security checks if needed, but why do you want to restrict multiple logins? Aren’t you just going to complicate your users’ lifes (and decrease productivity) without getting any advantage from it?