ActiveDirectory Error 0x8000500c with Bypass Properties

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
+5
4

, , ( ) , schema.refresh()

. , , .

+3

Err.exe

http://www.microsoft.com/download/en/details.aspx?id=985

:
  hex 0x8000500c/decimal -2147463156:
E_ADS_CANT_CONVERT_DATATYPE adserr.h
  /   DS
  1 "0x8000500c"

Googled " / " KB: http://support.microsoft.com/kb/907462

+3

. 0x8000500c, DirectoryEntry. Process Monitor (Sysinternals), . C:.\Users\\AppData\Local\Microsoft\Windows\SchCache\xyz.sch

, :)

+1

, -. , Windows IIS AD.

using (var context = new PrincipalContext(ContextType.Domain))
{
    var name = UserPrincipal.Current.DisplayName;
    var principal = UserPrincipal.FindByIdentity(context, this.user.Identity.Name);
    if (principal != null)
    {
        this.fullName = principal.GivenName + " " + principal.Surname;
    }
    else
    {
        this.fullName = string.Empty;
    }
}

, -, FindByIdentity.

, -. , .

0
source

All Articles