Active Directory custom attribute can not be seen by it's owner on some computers

0

A added a custom attribute to the Active Directory Schema. On one machine when I try to query the attribute I get errors back from my code.

Here is the C# version to test this out.

static class Program
{
    static void Main()
    {
        Console.ReadLine();
        DirectoryEntry directoryEntry = (DirectoryEntry)UserPrincipal.Current.GetUnderlyingObject();

        //Execption on this line
        var allowedDatabases = directoryEntry.Properties["vwDBAccess"]; 

        foreach (var record in allowedDatabases.OfType<String>())
        {
            Console.WriteLine(record);
        }
        Console.ReadLine();
    }

}
System.Runtime.InteropServices.COMException was unhandled
  Message=Unknown error (0x8000500c)
  Source=System.DirectoryServices
  ErrorCode=-2147463156
  StackTrace:
       at System.DirectoryServices.PropertyValueCollection.PopulateList()
       at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName)
       at System.DirectoryServices.PropertyCollection.get_Item(String propertyName)
       at Sandbox_Console.Program.Main() in C:\Users\srchamberlain.VW\documents\visual studio 2010\Projects\Sandbox Console\Sandbox Console\Program.cs:line 16
  InnerException: 

The Error Code 0x8000500c represents E_ADS_CANT_CONVERT_DATATYPE. This only happens on one machine. I have 3 other computers (all part of the same domain as the first computer) and those behave correctly when running the exact same code for the exact same user and give the the content of the attribute. Also if I run as a different user, on the same box, but query the bad user's attributes I can pull up the information correctly when connecting as another user.

I have tried refreshing the schema on the box using the technique from this KB article but the issue is still happening.

What is going wrong on this one computer?


Clarification:

vwDBAccess is a multivalued string, so when it works directoryEntry.Properties["vwDBAccess"] return a string with there is one item, sting[] when there is more than one, and null when there are no items. This account has 3 items set. When I run as a different user and query the bad user I correctly get string[3] returned.

c#
active-directory
asked on Stack Overflow Oct 11, 2012 by Scott Chamberlain • edited Oct 11, 2012 by Scott Chamberlain

1 Answer

1

Typically if something is only happening on one machine in a network then it boils down to service pack and update levels of the OS or interaction with other software on the system (A/V is the worst offender).

The first thing I would do is look at the SP and updates applied to the working machines, then compare that to the non-working one. You should see one of two situations:

If the working machines are more up to date, then apply whatever updates are necessary to the non-working machine.

If the working machines are less up to date, then update one and see if it starts failing. If that's the case, you might need to contact MS.

My gut says that the non-working machine is simply out of date.

answered on Stack Overflow Oct 11, 2012 by NotMe

User contributions licensed under CC BY-SA 3.0