I've been bumping my head over this for a while. I've found many questions asked regarding this on the internet but none had an actual answer.
My goal is to read & copy certain properties from one object in LDAP to another.
I can do it for all the properties without a problem, except for one property. Trying to access that specific property from a DirectoryEntry object results in the following error & exception: Unknown error (0x8000500c) & 'P' threw an exception of type 'System.Runtime.InteropServices.COMException.
I noticed that the SearchResult object holds a byte[] object as a value of that property, while the other properties are simply strings. So, reading the SearchResult object is no problem, I can get the byte[] and convert it to a string if I want to. The problem is that I need to get this value, and copy it into another object in LDAP, and that is done using the DirectoryEntry object of the SearchResult object (I get it using the GetDirectoryEntry method).
Let me try to explain the problem:
In LDAP, I have two objects - 'A' and 'B'.
I need to copy a property 'P' from A into B.
Property 'P' comes as byte[] object (even though in JXplorer I read & update it manually as a string).
Trying to access a property 'P' from the DirectoryEntry object results in a System.Runtime.InteropServices.COMException exception; I think I read somewhere that it's related to the data type, that it doesn't know how to read/convert it (byte[]).
The property 'P' of the SearchResult object holds a byte[] (instead of simply a string, ideally, like the other properties:
)
I'm unable to access the property 'P' from the DirectoryEntry object; I've shown in above SS that the property exists (I can also see the property name in the DirectoryEntry itself, but not the property value):
I'm able to access any other property from the same DirectoryEntry object: 
Help would be appreciated.
I was able to work around this issue on the same day I posted this question, by writing a custom class that handles the operations on properties that the current direct methods were unable to do. The methods can also be defined as extension methods, but I decided not to do it.
This is the method I used to convert the property that holds an array of TV PINs as an array of byte[] into a list of strings: