C# PrincipalOperationException 1355但WireShark表示成功

C# PrincipalOperationException 1355但WireShark表示成功,c#,directoryservices,userprincipal,C#,Directoryservices,Userprincipal,我有一个应用程序在应用程序域之外执行UserPrincipal(和GroupPrincipal)FindByIdentityWithType。这一直持续到上周。从那时起,我在我的开发机器上安装了Visual Studio 2012,我的代码停止使用PrincipalOperationException{“无法检索有关域的信息(1355)。”。windows错误号是80131501 我不知道VS2012安装、某些安全更新和此错误的出现之间是否存在关联 我在创建上下文时使用SimpleBind,并且

我有一个应用程序在应用程序域之外执行
UserPrincipal
(和
GroupPrincipal
FindByIdentityWithType
。这一直持续到上周。从那时起,我在我的开发机器上安装了Visual Studio 2012,我的代码停止使用
PrincipalOperationException
{“无法检索有关域的信息(1355)。”。windows错误号是80131501

我不知道VS2012安装、某些安全更新和此错误的出现之间是否存在关联

我在创建上下文时使用SimpleBind,并且在ADSIEdit中使用相同的设置来访问域仍然有效

我在一次应用程序测试中捕获了WireShark:TCP/LDAP包表明成功!我收到LDAP搜索结果包,可以看到它的内容在wireshark中是正确的。您可以在wireshark中看到searchRequest和searchResponse-请求的值是正确的,并且请求得到了正确的目录对象的响应。在收到错误之前,我可以看到在我的客户端和2008R2服务器之间的ldap通信中有一个端口改变。客户端是Windows7(我没有安装防火墙,我尝试使用禁用的病毒扫描程序)

我想稍后当System.DirectoryServices.AccountManagement实例化UserPrincipal时可能会出现问题(我尝试了这个,因为我怀疑我的一些UserPrincipalEx属性可能是异常的原因)。这种猜测是基于ldap查询的执行和回答都很好这一事实

我知道,如果您的客户端不受DirectoryObject的信任,您永远无法在该域上执行像
MemberOf
这样的方法。但UserPrincipal的简单实例化在我的工作中持续了几个月,直到今天

在我的开发环境中,我使用主机条目而不是DNS。它工作了几个月。服务器没有客户端的DNS知识,也从未有过

对解决方案的任何提示都将非常好

主机条目:

192.168.19.101  mhvtest.loc #thats the domain (local vmware) entry
192.168.19.101  mhvdc1.mhvtest.loc #thats the domain controller entry
192.168.19.102  mhvex1.mhvtest.loc
Stacktrace是:

   at System.DirectoryServices.AccountManagement.Utils.GetDcName(String computerName, String domainName, String siteName, Int32 flags)
   at System.DirectoryServices.AccountManagement.ADStoreCtx.LoadDomainInfo()
   at System.DirectoryServices.AccountManagement.ADStoreCtx.get_DnsDomainName()
   at System.DirectoryServices.AccountManagement.ADStoreCtx.GetAsPrincipal(Object storeObject, Object discriminant)
   at System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRefHelper(Type principalType, String urnScheme, String urnValue, DateTime referenceDate, Boolean useSidHistory)
   at System.DirectoryServices.AccountManagement.ADStoreCtx.FindPrincipalByIdentRef(Type principalType, String urnScheme, String urnValue, DateTime referenceDate)
   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate)
   at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, String identityValue)
   at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, String identityValue)
   at Idda2.ActiveDirectory.UserPrincipalEx.FindByIdentity(PrincipalContext context, String identityValue) in D:\Users\vogt\Documents\src\idda2\trunk\Idda2.ActiveDirectory\UserPrincipalEx.cs:line 130

请提供引发的异常的堆栈跟踪。已提供Stacktrace。新闻:使用AccountManagement命名空间比使用旧的DirectoryEntry对象会导致更多的ldap流量。再加上对域信任/成员身份的不可预测的依赖关系以及windows 2008r2服务器在上述1355(80131501)错误之前触发的网络ldap流量tcp重置,AccountManagement似乎不适用于我的情况。我将切换到DirectoryEntry并发布我的用户信息。其他用户也有同样的问题,并且已经向microsoft报告了。看见