ActiveDirectory error 0x8000500c when traversing properties(遍历属性时 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:遍历属性时 ActiveDirectory 错误 0x8000500c
基础教程推荐
- 从 VB6 迁移到 .NET/.NET Core 的最佳策略或工具 2022-01-01
- 我什么时候应该使用 GC.SuppressFinalize()? 2022-01-01
- 当键值未知时反序列化 JSON 2022-01-01
- C# - 如何列出发布到 ASPX 页面的变量名称和值 2022-01-01
- 创建属性设置器委托 2022-01-01
- 如何使用OpenXML SDK将Excel转换为CSV? 2022-01-01
- 覆盖 Json.Net 中的默认原始类型处理 2022-01-01
- C# - 将浮点数转换为整数...并根据余数更改整数 2022-01-01
- 使用 SED 在 XML 标签之间提取值 2022-01-01
- Page.OnAppearing 中的 Xamarin.Forms Page.DisplayAlert 2022-01-01