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
Jayarami Reddy 1Jayarami Reddy 1 

create an email alert that notifies to Admin of a failed login attempt after 3 attempts

Hi,

How can i create email alert to Admin when failed login attempt after 3 attempts in salesforce.

Thanks,
Jay
AnudeepAnudeep (Salesforce Developers) 
Hi Jay, 

Auto notification for failed logins is an Idea today

https://success.salesforce.com/ideaView?id=08730000000cBTUAA2

However, you can handle login errors based on Salesforce's recommendations for handling and troubleshooting failed logins (In the try, catch you can add messaging.singleEmailMessage to send emails). You can find more information in the article below

https://help.salesforce.com/articleView?id=000334674&type=1&mode=1 (https://help.salesforce.com/articleView?id=000334674&type=1&mode=1)
 
try { // Using binding already set up, log in LoginResult = binding.login(username, password); // Process successful LoginResult ... } catch (LoginFault loginFault) { ExceptionCode exCode = loginFault.getExceptionCode(); if (exCode == ExceptionCode.PASSWORD_LOCKOUT) { // User login has exceeded number of failed password attempts // Provide details to user or log String errMsg = loginFault.getMessage(); ... // Exit and do not re-attempt to login with this user ... } if (exCode == ExceptionCode.INVALID_LOGIN) { // Invalid password or credentials // Provide details to user or log String errMsg = loginFault.getMessage(); ... // Have user provide correct credentials and re-attempt login ... } // Process other possible errors ... }

Let me know if this helps by marking this as solved so that it can help others in future. Thank You!

Anudeep