0

we have migrated the asp.net application from .net framework 3.5, iis 7.0, Windows server 2008 R2 to .net framework 3.5, iis 8.5, Windows server 2012. AD is not working properly. once the app pool recycled, application working after sometime it is not working.

I'm getting the following intermittent errors related to querying AD using DirectorySearcher.FindOne() or FindAll().

System.DirectoryServices.DirectorySearcher causing “Arithmetic operation resulted in overflow” errors

System.OverflowException: Arithmetic operation resulted in an overflow. at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.GetCurrentResult() at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.get_Current() at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.System.Collections.IEnumerator.get_Current()

1 Answers1

0

Seems, like the same issue as described here:

System.DirectoryServices.DirectorySearcher causing "Arithmetic operation resulted in overflow" errors

One solution is to recycle the app pool more frequent. The other one (if you have access to source code) is to replace DirectorySearcher.FindXXX methods with LDAP-based classes from System.DirectoryServices.Protocols namespace (LdapConnection, SearchRequest, etc.)

Community
  • 1
  • 1
oldovets
  • 695
  • 4
  • 9
  • can you explain how i can implement LdapConnection using System.DirectoryServices.Protocols instead of DirectorySearcher.Findone() ? – Kannan Nagaraj Sep 20 '16 at 10:00
  • The following link explains how to create an LDAP searcher similar to DirectorySearcher: http://dunnry.com/blog/2008/06/05/PagedAsynchronousLDAPSearchesRevisited.aspx. You can change the searcher to work synchronously if needed – oldovets Sep 20 '16 at 10:50
  • LdapConnection asking username and password. but in my case i wont check with password . i need to verify with only username. – Kannan Nagaraj Sep 22 '16 at 12:09
  • In asp.net your app should be configured to impersonate under domain user account. In this case you can create LdapConnection without providing username and password (like in LdapSearher example above). That is how, I believe, DirectoryEntry works in your app at the moment. If my guess is wrong please clarify how your app works with DirectoryEntry at the moment – oldovets Sep 22 '16 at 13:10