I got the following code snippet ( SomeName/ SomeDomaincontains 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);
}
It prints OK for the first 21 properties, but with an error:
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 this?
Update
This is a non-standard attribute that does not work.
I tried using entry.RefreshCache()and entry.RefreshCache(new[]{"theAttributeName"})before listing the properties (which did not help).
Update2
entry.InvokeGet("theAttributeName")works (and without RefreshCache).
Can someone explain why?
Update3
It works if I put the FQDN for the item: LDAP://srv00014.ssab.com/CN=SomeName,xxxx
Bounty
I am looking for an answer that relates to the following:
- Why
entry.Properties["customAttributeName"]does not work with the specified exception - Why
entry.InvokeGet("customAttributeName")does it work - Reason for exclusion
- How to get both workers