遍历属性时 ActiveDirectory 错误 0x8000500c

时间:2022-11-10
本文介绍了遍历属性时 ActiveDirectory 错误 0x8000500c的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我得到了以下代码段(SomeName/SomeDomain 在我的代码中包含真实值)

I got the following snippet (SomeName/SomeDomain contains real values in my code)

var entry = new DirectoryEntry("LDAP://CN=SomeName,OU=All Groups,dc=SomeDomain,dc=com");
foreach (object property in entry.Properties)
{
    Console.WriteLine(property);
}

前 21 个属性打印正常,但随后失败:

It prints OK for the first 21 properties, but then fail with:

COMException {"Unknown error (0x8000500c)"}
   at System.DirectoryServices.PropertyValueCollection.PopulateList()
   at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
   at System.DirectoryServices.PropertyCollection.PropertyEnumerator.get_Entry()
   at System.DirectoryServices.PropertyCollection.PropertyEnumerator.get_Current()
   at ActiveDirectory.Tests.IntegrationTests.ObjectFactoryTests.TestMethod1() in MyTests.cs:line 22

为什么?我该如何预防?

Why? How can I prevent it?

更新

这是一个失败的自定义属性.

It's a custom attribute that fails.

在枚举属性之前,我尝试使用 entry.RefreshCache()entry.RefreshCache(new[]{"theAttributeName"})t帮助).

I've tried to use entry.RefreshCache() and entry.RefreshCache(new[]{"theAttributeName"}) before enumerating the properties (which didn't help).

更新 2

entry.InvokeGet("theAttributeName") 有效(并且没有 RefreshCache).

entry.InvokeGet("theAttributeName") works (and without RefreshCache).

有人能解释一下原因吗?

Can someone explain why?

更新 3

如果我为项目提供 FQDN 就可以了:LDAP://srv00014.ssab.com/CN=SomeName,xxxx

It works if I supply the FQDN to the item: LDAP://srv00014.ssab.com/CN=SomeName,xxxx

赏金

我正在寻找解决以下问题的答案:

I'm looking for an answer which addresses the following:

  • 为什么 entry.Properties["customAttributeName"] 因上述异常而失败
  • 为什么 entry.InvokeGet("customAttributeName") 有效
  • 异常的原因
  • 如何让两者都工作
  • Why entry.Properties["customAttributeName"] fails with the mentioned exception
  • Why entry.InvokeGet("customAttributeName") works
  • The cause of the exception
  • How to get both working

推荐答案

如果想要从一台非自定义属性所在域的一部分(凭据登录用户的无关紧要)需要完全通过对象的限定名称正在尝试访问,否则模式客户端机器上的缓存没有正确刷新,没关系您所做的 schema.refresh() 调用

If one wants to access a custom attribute from a machine that is not part of the domain where the custom attribute resides (the credentials of the logged in user don't matter) one needs to pass the fully qualified name of the object is trying to access otherwise the schema cache on the client machine is not properly refreshed, nevermind all the schema.refresh() calls you make

在此处找到.鉴于对问题所做的更新,这听起来像是您的问题.

Found here. This sounds like your problem, given the updates made to the question.

这篇关于遍历属性时 ActiveDirectory 错误 0x8000500c的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:使用通配符按 samaccountname 搜索 下一篇:没有了

相关文章

最新文章