I am trying to enumerate the values in a SearchResultCollection.
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?
Thanks
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.
User contributions licensed under CC BY-SA 3.0