相关疑难解决方法(0)

System.DirectoryServices.DirectorySearcher导致"算术运算导致溢出"错误

我收到以下与使用DirectorySearcher.FindOne()或查询AD相关的间歇性错误 FindAll().

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()
Run Code Online (Sandbox Code Playgroud)

这是在一个Web应用程序中发生的,似乎是在应用程序运行了几个小时后发生的.

这是Microsoft Connect上的文档问题,但看起来它已标记为"不可重现"并已关闭.

我在这里找到的唯一解决方案是定期回收应用程序池,这是一个相当苛刻的解决方法,当用户处于工作中时不可行.

有没有人经历过这个,如果是这样,这是如何解决的?

我曾尝试使用缓存,但这只会延迟不可避免的事情,直到你达到AD调用次数的某个阈值,因为人们已经报告每次调用API时它会泄漏内存.

任何帮助将非常感激.

.net directoryservices memory-leaks active-directory

23
推荐指数
1
解决办法
2099
查看次数

COMException未知错误(0x80005000) - DirectoryServices

我在我的一个应用程序上遇到错误,每个月发生几次,但本周发生了两次.当这种情况发生时,第一个用户加载应用程序并开始工作时,它总是第一件事(Web应用程序,3-4个内部用户)错误源于这个非常简单的方法,一旦失败,它将无法工作,直到我重启应用程序池.现在,我也以其他方式查询AD,但这是用户在早上开始工作时调用的第一个AD相关方法.

public DomainUser GetDomainUser(string userLoginName)
    {
        using (PrincipalContext context = new PrincipalContext(ContextType.Domain, this.DomainName))
        {
            using (UserPrincipal user = UserPrincipal.FindByIdentity(context, userLoginName))
            {
                // If user is null, the result is not a UserPrinciple
                if (user != null)
                {
                    string firstName = user.GivenName;
                    string middleName = user.MiddleName;
                    string lastName = user.Surname;
                    int empId = Convert.ToInt32(user.EmployeeId);
                    string emailAddr = user.EmailAddress;
                    string userName = user.SamAccountName;
                    DateTime? accountExp = user.AccountExpirationDate;

                    return new DomainUser
                    {
                        FirstName = firstName,
                        MiddleName = middleName,
                        LastName = lastName,
                        EmployeeId = …
Run Code Online (Sandbox Code Playgroud)

asp.net directoryservices active-directory account-management

5
推荐指数
1
解决办法
4421
查看次数