We may find ourselves in the situation where we need to access custom properties that have been defined for objects in our Active Directory. However, using the managed class
DirectoryEntry we may receive an exception with the error code 0x8000500CL when accessing the custom property the following way:
As the error text indicates, the cause for this issue is the lack of information about how to convert the value of our custom property into a managed object.
DirectoryEntry does not offer the possibility to specify this meta information, so how can we access our custom properties?
Luckily there is COM library, ActiveDS, which exposes (amongst others) the following two functions:
Once we add a reference to the library to our Visual Studio project, selecting it from the COM tab (it appears as “Active DS Type Library“), we can implement a wrapper like the following:
public static List
We can then access our custom property using the following call:
var sReturnValues = PropertyHelper.GetProperty(entry, "sAttribute", ADSTYPEENUM.ADSTYPE_CASE_IGNORE_STRING);
Implementing a similar wrapper for setting the values of our custom property should be straightforward from here. I hope this helps.