Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Active Directory中的间歇性未知错误_C#_Asp.net_.net_Active Directory_Directoryservices - Fatal编程技术网

C# Active Directory中的间歇性未知错误

C# Active Directory中的间歇性未知错误,c#,asp.net,.net,active-directory,directoryservices,C#,Asp.net,.net,Active Directory,Directoryservices,我正在使用.Net帐户管理库访问Active Directory以搜索当前http请求用户的详细信息。 我的应用程序池使用自定义帐户运行,它也来自同一个域。服务器和用户也属于同一个域 public string GetEmployeeId(string SAMAccountName) { using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain)) { using (UserPrincipal

我正在使用.Net帐户管理库访问Active Directory以搜索当前http请求用户的详细信息。 我的应用程序池使用自定义帐户运行,它也来自同一个域。服务器和用户也属于同一个域

public string GetEmployeeId(string SAMAccountName)
{
using (PrincipalContext domainContext = new PrincipalContext(ContextType.Domain))
{
using (UserPrincipal userprincipal = new UserPrincipal(domainContext))
{
userprincipal.SamAccountName = SAMAccountName; 
using (PrincipalSearcher ps = new PrincipalSearcher()) 
{
ps.QueryFilter = userprincipal; 
UserPrincipal user = ps.FindOne() as UserPrincipal;
return user.EmployeeId; 
}
}
}
}
安装工作完美,但间歇性我得到以下错误的广告。经过一段时间,它的工作为同一个用户没有任何错误

是否有任何方法可以从AD端检查日志/事件,以找到此错误的原因

System.Runtime.InteropServices.COMException(0x80005000):未知错误>(0x80005000)


尝试确定您将使用的域服务器:

比如:
=新的PrincipalContext(ContextType.Domain,“YOURADDOMAIN”)

我与一位微软工程师合作了很长一段时间来解决这个问题,所以希望我的解决方案能够帮助其他人解决他们的问题

首先,传递了错误代码0x80005000 referers到无效的ADSI路径名,这不是特别有用

我们做了很多追踪,但也没有什么帮助。我们做的最后一件事是使用进程监视器跟踪注册表

当错误发生时,我注意到发生了一个配置单元卸载结果(参见屏幕截图)

基于此,我们还发现此错误出现在事件日志中

Log Name:      Application 
Source:        Microsoft-Windows-User Profiles Service 
Date:          10/26/2009 8:22:13 AM 
Event ID:      1530 
Task Category: None 
Level:         Warning 
Keywords:      Classic 
User:          SYSTEM 
Computer:      SERVERNAME 
Description: 
Windows detected your registry file is still in use by other applications or services. The file will be unloaded now. The applications or services that hold your registry file may not function properly afterwards.  
DETAIL - 
1 user registry handles leaked from \Registry\User\S-1-5-21-1049297961-3057247634-349289542-1004_Classes: 
Process 2428 (\Device\HarddiskVolume1\Windows\System32\dllhost.exe) has opened key \REGISTRY\USER\S-1-5-21-1123456789-3057247634-349289542-1004_CLASSES
工程师提出了这篇文章


这似乎解决了我的问题

谢谢你的评论,先生。但据我所知,这个服务器问题发生在2000年,我们的版本是2012年。我有同样的问题,但它不会马上发生。一旦发生,它会一直保持这种状态,直到我手动回收应用程序池。我也有同样的问题,就像icedek一样,一旦发生,它会被卡住,直到我手动回收应用程序池。谢谢你的回复,先生。我的服务器、应用程序池和客户端用户都来自同一个域。这段代码可以工作,但有时客户机会收到此错误,之后它会完全适用于相同的客户机。我认为这是广告方面的错误。