function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
renuamirenuami 

User login history

Hi

 

Is there an option to query user login history in Apex? If so can someone please provide an example or any documentation?

 

 

Thanks

WizradWizrad

You can [SELECT LastLoginDate FROM User].

 

The only way I could imagine you being able to get a longer history is to have field tracking enabled on that field, which I am pretty sure isn't possible.

Rakesh BoddepalliRakesh Boddepalli

Yes You can, 

You can fire the SOQL query on the Loginhistory table.

check this link http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_loginhistory.htm for further information .

Dinesh1617Dinesh1617
Actually "Login History" is an Object in Salesforce..
So get into the workbench or data loader, select that perticular Object and select the fields what are required for you requirement.