我想列举在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.