+ Start a Discussion
Sharankumar DesaiSharankumar Desai 

Apex Code to get Logged In users List

Hi All,

I am looking for an Apex code which can get me a list of all current logged In users.

Let me know if this is feasible.

Thanks
Sharan Desai
+91 966 33 11 740
bob_buzzardbob_buzzard
You can't do this in Apex I'm afraid. You can get at session information via the SOAP api :

https://developer.salesforce.com/docs/atlas.en-us.api.meta/api/sforce_api_objects_authsession.htm#sforce_api_objects_authsession

So you could query all sessions that aren't considered expired - note that this doesn't mean that they are active.  You can access the SOAP API via JavaScript using the Ajax toolkit, so you would be able to get the list of users back to a Visualforce controller and thus into Apex, but you can't access the SOAP api via Apex in a supported fashion.
Sharankumar DesaiSharankumar Desai
Thanks Bob..