How to Assign one user rights to other user by code in MSD axapta

You can try following code in Job or you can apply in form controls event.

 UserGroupList UsergroupList1,UsergroupList2;  
 UserId FromUserId, ToUserId;  
 FromUserId = 'usr1';  
 ToUserId = 'usr2' ;  
 delete_from UsergroupList1  
 where UsergroupList1.UserId == ToUserId;  
 while select UsergroupList1 where UsergroupList1.userId == FromUserId  
 info(strfmt('Group assigned: %1',UsergroupList1.groupId));  
 select forupdate UsergroupList2 where UsergroupList2.userID == ToUserId && UsergroupList2.GroupId == UsergroupList1.GroupId;  
 UsergroupList2.UserId = ToUserId;  
 UsergroupList2.GroupId = UsergroupList1.GroupId;  
 info(strfmt('Permissions changed for %1',ToUserId));