0

A 向 Active Directory 架构添加了自定义属性。在一台机器上,当我尝试查询属性时,我从代码中返回错误。

这是用于测试的 C# 版本。

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 未处理
  消息=未知错误 (0x8000500c)
  源 = System.DirectoryServices
  错误代码=-2147463156
  堆栈跟踪:
       在 System.DirectoryServices.PropertyValueCollection.PopulateList()
       在 System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry 条目,字符串 propertyName)
       在 System.DirectoryServices.PropertyCollection.get_Item(字符串属性名称)
       在 C:\Users\srchamberlain.VW\documents\visual studio 2010\Projects\Sandbox Console\Sandbox Console\Program.cs:line 16 中的 Sandbox_Console.Program.Main()
  内部异常:

错误代码0x8000500c代表E_ADS_CANT_CONVERT_DATATYPE。这只发生在一台机器上。我有 3 台其他计算机(与第一台计算机位于同一域的所有部分),并且在为完全相同的用户运行完全相同的代码并给出属性内容时,它们的行为正确。此外,如果我以不同用户的身份在同一个盒子上运行,但查询坏用户的属性,我可以在以另一个用户身份连接时正确提取信息。

我尝试使用此知识库文章中的技术刷新盒子上的架构,但问题仍然存在。

这台电脑出了什么问题?


澄清:

vwDBAccess 是一个多值字符串,所以当它工作时directoryEntry.Properties["vwDBAccess"]返回一个string有一个项目,sting[]当有多个项目时,以及null没有项目时。此帐户设置了 3 个项目。当我以其他用户身份运行并查询坏用户时,我会正确string[3]返回。

4

1 回答 1

1

通常,如果某些事情只发生在网络中的一台机器上,那么它归结为操作系统的服务包和更新级别或与系统上其他软件的交互(A/V 是最严重的违规者)。

我要做的第一件事是查看应用于工作机器的 SP 和更新,然后将其与非工作机器进行比较。您应该看到以下两种情况之一:

如果工作机器是最新的,则对非工作机器应用任何必要的更新。

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.

于 2012-10-11T17:37:56.573 回答