I created Asp.Net Mvc web application w/c is using windows authentication. My requirement is capture and log invalid login attempts but don't know how to do it. Tried to google but no luck.
- List item How to capture user name input from authentication popup?
- List item Is there setting to limit login pop up after consecutive login failed. It works on Internet Explorer (IE),It display 401 unauthorized after 3 consecutive login attempts but Firefox and Mozilla do not have limits.
Here is what i tried so far. Using below code,
- List item I'm trying to capture unauthorized error unfortunately event only fire when i click cancel for Firefox and Mozilla.
List item It fires after 3 invalid attempts in IE but don't know how to get user name input. Global.asax
protected void Application_EndRequest(Object sender, EventArgs e) { HttpContext context = HttpContext.Current; if (context.Response.Status.Substring(0, 3).Equals("401")) { //Capture user name for further processing // context.Response.ClearContent(); context.Response.Write("You are un authorized "); } }
Thanks in advance, hope someone can help.
HttpContext.Current.Request.ServerVariables["LOGON_USER"]but since login was unsuccessful then access is anonymous. Perhaps this situation requires a different approach.