为什么我会得到一个0x8000500c错误的.Net枚举SearchResultCollection时 [英] Why am I getting a 0x8000500c error when enumerating a SearchResultCollection in .Net

查看:250
本文介绍了为什么我会得到一个0x8000500c错误的.Net枚举SearchResultCollection时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想列举在SearchResultCollection的值。

I am trying to enumerate the values in a SearchResultCollection.

一切编译罚款,但我得到这条线上的0x8000500c错误:

Everything compiles fine, but I get the 0x8000500c error on this line:

foreach (PropertyValueCollection e in de.Properties.Values)
{
    sw.WriteLine(e.Value);
}

完整方法如下:

Full method is below:

private static void GetValues()
{
    var directoryEntry = new DirectoryEntry("LDAP://8.8.8.8:8888", "foo", "bar",
                                                       AuthenticationTypes.None);
    var ds = new DirectorySearcher(directoryEntry);
    var final = ds.FindAll();

    var sw = new StreamWriter(@"C:\z\FooBar.txt");

    var titlesDone = false;

    foreach (var de in from SearchResult x in final select x.GetDirectoryEntry())
    {
        if (!titlesDone)
        {
            foreach (string d in de.Properties.PropertyNames)
            {
                sw.WriteLine(d);
                titlesDone = true;
            }
        }


        foreach (PropertyValueCollection e in de.Properties.Values)
        {
            //I get the error on the below line
            sw.WriteLine(e.Value);
        }
    }

    sw.Flush();
    sw.Close();
}

你能不能帮我弄清楚这是为什么不工作?

Can you help me figure out why this isn't working?

感谢

推荐答案

Active Directory的错误codeS列出AdsErr.h SDK头文件:

Active Directory error codes are listed in the AdsErr.h SDK header file:

//
// MessageId: E_ADS_CANT_CONVERT_DATATYPE
//
// MessageText:
//
//  The directory datatype cannot be converted to/from a native DS datatype
//
#define E_ADS_CANT_CONVERT_DATATYPE      _HRESULT_TYPEDEF_(0x8000500CL)

所以,问题是在电线的另一端​​,有某种在目录条目,它不知道如何转换成通用数据类型不寻常的自定义属性。聊到服务器管理员获得这个解决,或者是更有选择性,你需要阅读的属性。

So the problem is on the other end of the wire, there's some kind of unusual custom property in the directory entry that it doesn't know how to convert to a common data type. Talk to the server admin to get this resolved or be more selective with the properties you need to read.

这篇关于为什么我会得到一个0x8000500c错误的.Net枚举SearchResultCollection时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆