fix: ldap_get_entries returns raw binary, remove incorrect base64 decode

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-28 20:53:49 -04:00
parent 18bf1fde0e
commit b40c404828
+2 -11
View File
@@ -130,17 +130,8 @@ try {
$entries = ldap_get_entries($ldap, $search); $entries = ldap_get_entries($ldap, $search);
if ($entries['count'] > 0 && !empty($entries[0]['avatar'][0])) { if ($entries['count'] > 0 && !empty($entries[0]['avatar'][0])) {
// lldap stores the avatar as a base64-encoded string in the LDAP attribute // ldap_get_entries() returns the attribute value as raw binary.
$avatarRaw = $entries[0]['avatar'][0]; $avatarData = $entries[0]['avatar'][0];
// ldap_get_entries already decodes binary attributes; but lldap stores
// the avatar as a base64 string within the attribute value itself.
// Detect: if it starts with /9j/ (JPEG magic in base64) decode it.
if (substr($avatarRaw, 0, 4) === '/9j/') {
$avatarData = base64_decode($avatarRaw);
} else {
// Raw binary JPEG (starts with FF D8)
$avatarData = $avatarRaw;
}
} }
ldap_unbind($ldap); ldap_unbind($ldap);