Assign single login per user in MSD axapta

Thia code is Assign single login per user in axapta I hope this will help you lot

 select count(recid) from clientSessions where clientSessions.userId==curuserid()  
 && clientSessions.Status!=0  
 && clientSessions.sessionType==0;  
 if(clientSessions.RecId>1)  
 {  
 for (i=1; i<=50; i++)  
 {  
 progress.incCount();  
 progress.setCaption('Login Error');  
 progress.setText(strfmt("User '%1' Already Taken login session ",curuserid()));  
 sleep(10);  
 }  
 infolog.shutDown(true);  
 }