On 03 Apr 2024, at 13:03, Ondřej Kuzník ondra@mistotebe.net wrote:
This has been historically vague - first off, what happens if an attempt is made to call ldap_get_values() on binary data, do you get an error, or garbage data? The source isn't giving me a clear answer.
Hi Graham, in this case binary data means embedded NULs (\0) can be found: given that what you get back is a naive char * for each value, you stand to lose information about whether that NUL is part of the value or a string terminator.
So that means garbage data is returned.
Second question is how do you know which of ldap_get_values() or ldap_get_values_len() to call? Obviously you can manually know this, but I'm interested in automated behaviour. What is the canonical way to discover that if you queried a jpegPhoto (for example) that the result would be binary?
You either expect the data to be a string of some sort (no embedded NULs), then you're free to use whichever or you are prepared to accept arbitrary bytestreams and you need to use the one that returns bervals. That's all there is.
So am I right in understanding there is no way to ask the server "what type is this attribute you just gave me, is this arbitrary octets or a NUL terminated string"?
You're welcome to propose better wording if you can make it clearer to a reasonably competent C developer (I'm sure we can assume that they understand how strings are laid out etc.)
The reason this matters has nothing to do with reasonably competent C developers, but rather options given to end users.
If the end user is allowed to provide an attribute in a configuration file, do I force the end user to know about binary values (as is common now), or is there a way I can be nice to the end user and have the system behave sensibly based on whether the return data is a string or binary?
Regards, Graham --