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:
+2
-11
@@ -130,17 +130,8 @@ try {
|
||||
|
||||
$entries = ldap_get_entries($ldap, $search);
|
||||
if ($entries['count'] > 0 && !empty($entries[0]['avatar'][0])) {
|
||||
// lldap stores the avatar as a base64-encoded string in the LDAP attribute
|
||||
$avatarRaw = $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_get_entries() returns the attribute value as raw binary.
|
||||
$avatarData = $entries[0]['avatar'][0];
|
||||
}
|
||||
|
||||
ldap_unbind($ldap);
|
||||
|
||||
Reference in New Issue
Block a user