I had a lot of issues with decoding errors using ldap_get_values_len() and found a of unanswered calls for help on a lot of forums.
The error message is - Warning: ldap_get_values(): Cannot get the value(s) of attribute Decoding error in xxx.php.
It appears that this error seems to cover a multitude sins including simple typos in the attribute name.
After using PHP to list the attributes of a particular record I noticed that the attribute userCertificate wasn't listed simply as userCertificate but userCertificate;binary instead. I wrote this into my code and all was fixed.
So my code looks as follows.
<?php
if (!$val = @ldap_get_values_len($con, $entry, "$attribute;binary"))
die ('Error retrieving value (' . ldap_error($con) . ')');
?>
I hope this saves someone the pain I went through trawling Google for an answer.