I have got HAP working absolutely fine for all users who login, however the issue occurs if an incorrect username (not password) is entered. When someone enters an incorrect username they get the below error message, how can I fix this?
[h=1]Server Error in '/HAP' Application.[/h][h=2]Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index[/h]Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Source Error:
[TABLE=width: 100%]
[TR]
[TD]An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.[/TD]
[/TR]
[/TABLE]
Stack Trace:
[TABLE=width: 100%]
[TR]
[TD][ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index]
System.Collections.ArrayList.get_Item(Int32 index) +14310269
System.DirectoryServices.SearchResultCollection.get_Item(Int32 index) +28
HAP.AD.User.UserAccountControl(String username) +146
HAP.Web.Login.login_Click(Object sender, EventArgs e) +1009
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +153
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3804
[/TD]
[/TR]
[/TABLE]
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009