How to get the UserID of all the currently logged in users using Apex code?
You can get the ID’s of all the currently logged in users by using this global function: UserInfo.getUserId().