jga*_*fin 5 c# directoryservices active-directory
我得到了以下代码段(SomeName/ SomeDomain在我的代码中包含实际值)
var entry = new DirectoryEntry("LDAP://CN=SomeName,OU=All Groups,dc=SomeDomain,dc=com");
foreach (object property in entry.Properties)
{
Console.WriteLine(property);
}
Run Code Online (Sandbox Code Playgroud)
它为前21个属性打印OK,但随后失败:
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
Run Code Online (Sandbox Code Playgroud)
为什么?我该怎样预防呢?
更新
这是一个失败的自定义属性.
我试图使用entry.RefreshCache()和entry.RefreshCache(new[]{"theAttributeName"})枚举属性(没有帮助)前.
UPDATE2
entry.InvokeGet("theAttributeName")工作(和没有RefreshCache).
有人可以解释原因吗?
UPDATE3
如果我向项目提供FQDN,它可以工作: LDAP://srv00014.ssab.com/CN=SomeName,xxxx
赏金
我正在寻找解决以下问题的答案:
entry.Properties["customAttributeName"]在提到的例外情况下失败entry.InvokeGet("customAttributeName")有效| 归档时间: |
|
| 查看次数: |
7181 次 |
| 最近记录: |